well, I'm also guilty of a Haskell dcpu16 emulator ;).
The memory access using Memory should be pretty fast, but what is the overhead of the MonadEmulator type class, of their load/store functions?
I used a Vector of unboxed Word16 for the ram and the ST monad to modfiy them.
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
set :: Integral a => V.Vector Word16 -> a -> Word16 -> V.Vector Word16
set vector index value = runST (setM vector (fromIntegral index) value)
where
setM vec i val = do
mVec <- V.unsafeThaw vec
VM.write mVec i val
V.unsafeFreeze mVec
Have you a feeling, can you estimate the performance difference of using a
Vector like this and your Memory?Greetings, Daniel