Skip to content

Instantly share code, notes, and snippets.

@roboguy13
Last active November 24, 2015 06:28
Show Gist options
  • Save roboguy13/ccc8ab946efa5abccf10 to your computer and use it in GitHub Desktop.
Save roboguy13/ccc8ab946efa5abccf10 to your computer and use it in GitHub Desktop.
import Data.Word
import Control.Applicative
import Data.Vector (Vector)
type EmuWord = Word32
data Emu a -- ...
instance Functor Emu
instance Applicative Emu
instance Monad Emu
instance MonadIO Emu
loadProgram :: Vector EmuWord -> Emu ()
nextInstruction :: Emu EmuWord
reset :: Emu ()
halt :: Emu ()
memGet :: EmuWord -> Emu EmuWord
memSet :: EmuWord -> EmuWord -> Emu ()
-- | Apply the given function over the given memory location range. Since
-- this is a pure function, this operation could be parallelized relatively
-- easily.
memSets :: (EmuWord -> EmuWord) -> EmuWord -> EmuWord -> Emu ()
-- | Add a memory map hook to the given range of memory locations
addMemMapHook :: (EmuWord -> Emu EmuWord) -> EmuWord -> EmuWord -> Emu ()
instrMemGet :: EmuWord -> Emu EmuWord
instrMemSet :: EmuWord -> EmuWord -> Emu ()
-- | Reorder two instructions by swapping them in the instruction memory
instrMemSwap :: EmuWord -> EmuWord -> Emu ()
regGet :: EmuWord -> Emu EmuWord
regSet :: EmuWord -> EmuWord -> Emu ()
getTicks :: Emu EmuWord
sliceWord :: Word8 -> Word8 -> EmuWord -> EmuWord
runEmu :: Emu a -> IO a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment