+ do cip <- gets _ip
+ (l, _) <- dissembleInstruction cip
+ registers <- gets _registers
+ let regVals = intercalate "; " $ fmap show $ M.elems registers
+ stack <- gets _stack
+ let stackVals = intercalate "; " $ fmap show $ take 10 stack
+ tell $ fmap (fromIntegral . ord) (">> " ++ l ++ " : r> " ++ regVals ++ " : s> " ++ stackVals ++ "<<")
+
+runDissemble :: Word16 -> Int -> Machine -> [String]
+runDissemble startAt num machine =fst $ evalRWS (dissemble startAt num) [] machine
+
+
+dissemble :: Word16 -> Int -> ProgrammedMachine [String]
+dissemble startAt num = go startAt num []
+ where go _ 0 ls = return $ reverse ls
+ go here n ls =
+ do (line, step) <- dissembleInstruction here
+ go (here + step) (n - 1) (line : ls)
+
+dissembleInstruction :: Word16 -> ProgrammedMachine (String, Word16)
+dissembleInstruction cip =
+ do -- cip <- gets _ip