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 -> State Source

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 -> State Source

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

traceAll :: State -> Trace Source

Trace the given program, including all the intermediate states.

traceProgram :: State -> Trace 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 -> Trace Source

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

eval :: State -> State Source

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

runNativeProgram :: State -> NativeProgram -> State Source

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 -> Double Source

Estimates the execution time of a program trace.

throttle :: Int -> Trace -> Either Trace Trace Source

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

endWord :: Opcode -> Bool Source

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 -> State Source

Executes an opcode on the given state. If the state is blocked on some communication, nothing changes.

jump :: Opcode -> F18Word -> State -> State Source

Execute a jump instruction to the given address.