Created
June 26, 2009 20:31
-
-
Save eklitzke/136720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- An Addr is really 14 bits, but this should be close enough | |
type Addr = Word16 | |
-- The status register | |
type StatusR = On | Off deriving (Show, Eq) | |
type Imm = LTZ | |
| LEZ | |
| EQZ | |
| GEZ | |
| GTZ deriving (Show, Eq, Ord, Enum) | |
data DOper = Add | |
| Sub | |
| Mult -- etc. | |
data DType = DOper Addr Addr | |
data SType = SOper (Maybe Imm) Addr | |
-- The program counter | |
type ProgramCounter = Addr | |
-- The instruction set is immutable | |
type Instructions = IArray Addr Word32 | |
-- Memory is mutable | |
type Memory = IOArray Addr Word64 | |
data World = World ProgramCounter StatusR Instructions Memory | |
-- Stepping through a single instruction is a function like World -> IO | |
-- World. The new world has an incremented ProgramCounter, and shares the same | |
-- reference to an Instruction array and Memory array. Since the memory array is | |
-- mutable, the old world shouldn't be used anymore (since its memory contents | |
-- will reflect the new state of the world). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment