Skip to content

Instantly share code, notes, and snippets.

@lincore81
Created October 26, 2018 17:36
Show Gist options
  • Save lincore81/c7999e827ec1cda2e31f9814b6e3b7cb to your computer and use it in GitHub Desktop.
Save lincore81/c7999e827ec1cda2e31f9814b6e3b7cb to your computer and use it in GitHub Desktop.
module Asm2 where
type Reg = Char
data Registers = Registers
{ a :: Int
, b :: Int
, c :: Int
, d :: Int
, ip :: Int
, sp :: Int
} deriving (Show, Eq, Ord)
data Addr
= Absolute Int
| Relative Int
| Immediate Int
| Register Reg
deriving (Show, Eq, Ord)
data Instruction
= Load Reg Addr -- put value in Addr in Reg
| Store Reg Addr -- store reg in addr
| Add Reg Reg
| Sub Reg Reg
| Mul Reg Reg
| Div Reg Reg
| Jiz Addr
deriving (Show, Eq, Ord)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment