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

Safe HaskellNone




type Memory = Vector IntSource

The chip's RAM and ROM

data State Source

A state representing the registers, stacks and memory of a core.




a :: !F18Word
b :: !F18Word
i :: !F18Word
p :: !F18Word
r :: !F18Word
s :: !F18Word
t :: !F18Word
dataStack :: !Stack
returnStack :: !Stack
memory :: !Memory


startState :: StateSource

The state corresponding to a core with no programs loaded and no instructions executed.

next :: State -> InstrsSource

The next word of instructions to execute in the given state.

dpop :: State -> (State, F18Word)Source

Pops the data stack of the given state, updating s and t.

dpush :: State -> F18Word -> StateSource

Push a word onto the data stack, updating s and t.

rpop :: State -> (State, F18Word)Source

Pops the return stack of the given state, updating r.

rpush :: State -> F18Word -> StateSource

Push a word onto the return stack, updating r.

toMem :: (Integral a, Integral b) => a -> bSource

Force an address to be in range of memory: [0,64).

(!) :: Memory -> F18Word -> F18WordSource

Read the memory at a location given by a Forth word.

set :: Memory -> F18Word -> F18Word -> MemorySource

Set the memory using Forth words.

setProgram :: F18Word -> NativeProgram -> State -> StateSource

Loads the given program into memory at the given starting position.

loadMemory :: F18Word -> [F18Word] -> State -> StateSource

Load the given memory words into the state starting at the given address.