Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Instrs
- type NativeProgram = [Instrs]
- splitWords :: (a -> Bool) -> [a] -> [[a]]
- readNativeProgram :: String -> Either ParseError NativeProgram
- toBits :: Instrs -> F18Word
- fromBits :: F18Word -> Instrs
- toOpcodes :: Instrs -> [Opcode]
- runningTime :: NativeProgram -> Double
Documentation
Represents a word in memory. This word can either contain opcodes, opcodes and a jump address or just a constant number.
type NativeProgram = [Instrs] Source
A program in the F18A instruction set.
splitWords :: (a -> Bool) -> [a] -> [[a]] Source
Splits a list into chunks of at most four, breaking off a chunk whenever it sees an element matching the given predicate. This is useful for splitting a program along word boundaries, accounting for jump addresses.
readNativeProgram :: String -> Either ParseError NativeProgram Source
Read a whole program, splitting instructions up into words.
toBits :: Instrs -> F18Word Source
Returns the given instructions as an actual word. This assumes the address is sized appropriately.
toOpcodes :: Instrs -> [Opcode] Source
Returns the opcodes in the given instruction word. A constant corresponds to not having any opcodes.
runningTime :: NativeProgram -> Double Source
Estimates the running time of the program in nanoseconds. This is based on the numbers provided in the manual: faster instructions take 1.5 nanoseconds and slower ones take 5. For now, this estimate ignores control flow like ifs and loops.