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

Safe HaskellNone




type Trace = [State]Source

A trace of a progam is the state after every word is executed.

wordAll :: Instrs -> State -> [State]Source

Runs a single word's worth of instructions starting from the given state, returning the intermediate states for each executed opcode.

word :: Instrs -> State -> StateSource

Runs a single word's worth of instructions, returning only the final state.

stepAll :: State -> [State]Source

Executes a single word in the given state, incrementing the program counter and returning all the intermediate states.

step :: State -> StateSource

Executes a single word in the given state, returning the last resulting state.q

traceAll :: State -> TraceSource

Trace the given program, including all the intermediate states.

traceProgram :: State -> TraceSource

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

stepProgram :: State -> TraceSource

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 :: Trace -> DoubleSource

Estimates the execution time of a program trace.

throttle :: Int -> Trace -> Either Trace TraceSource

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?

run :: Opcode -> [State] -> [State]Source

Extends the given trace by a single execution step. The trace cannot be empty.

execute :: Opcode -> State -> StateSource

Executes an opcode on the given state.

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

Execute a jump instruction to the given address.