array-forth- A simple interpreter for arrayForth, the language used on GreenArrays chips.

Safe HaskellNone




word :: Instrs -> State -> StateSource

Runs a single word's worth of instructions starting from the given state.

step :: State -> StateSource

Executes a single instruction in the given state, incrementing the program counter.

traceProgram :: State -> [State]Source

Returns a trace of the program's execution. The trace is a list of the state of the chip after each step.

stepProgram :: State -> [State]Source

Trace a program until it either hits four nops or all 0s.

eval :: State -> StateSource

Runs the program unil it hits a terminal state, returning only the resulting state.

runNativeProgram :: State -> NativeProgram -> StateSource

Executes the specified program on the given state until it hits a terminal word--a word made up of four nops or all 0s.

countTime :: [State] -> DoubleSource

Estimates the execution time of a program trace.

throttle :: Int -> [State] -> Either [State] [State]Source

Checks that the program trace terminated in at most n steps, returning Nothing otherwise.

endWord :: Opcode -> BoolSource

Does the given opcode cause the current word to stop executing?

execute :: Opcode -> State -> StateSource

Executes an opcode on the given state.

jump :: Opcode -> F18Word -> State -> StateSource

Execute a jump instruction to the given address.