As discussed previously, variables STATE, HERE, LATEST, TIB should be stored at memory addresses, not in registers.
Below are a few ideas which could help you:
- Store each variable at a memory location right below
TIB_BASE_ADDR = 0x3000:
TIB = TIB_BASE_ADDR - 4
LATEST = TIB - 4
HERE = LATEST - 4
STATE = HERE - 4
- Since the values are in memory instead of registers, the
body_fun needs a small change, example:
body_latest:
li t0, LATEST # load memory address into temporary
lw t0, 0(t0) # load address stored at LATEST into temporary
sw t0, 0(DSP) # store address to top of data stack
addi DSP, DSP, 4 # increment data stack by 32-bits
j next
- Repeat for
body_state, body_tib, etc... Well you know, there's quite a few other places this is needed, but if you had macros you could write one which performs those first two instructions (li and lw), so anywhere derzforth.asm makes use of LATEST, STATE, HERE, TIB could be replaced with t0 or something like that.. just a thought (I realize it's not going to be that simple).
I don't know if the above code is correct since I haven't tested it, but I think that's the idea.
As discussed previously, variables
STATE, HERE, LATEST, TIBshould be stored at memory addresses, not in registers.Below are a few ideas which could help you:
TIB_BASE_ADDR = 0x3000:body_funneeds a small change, example:body_state, body_tib, etc... Well you know, there's quite a few other places this is needed, but if you had macros you could write one which performs those first two instructions (liandlw), so anywherederzforth.asmmakes use ofLATEST, STATE, HERE, TIBcould be replaced witht0or something like that.. just a thought (I realize it's not going to be that simple).I don't know if the above code is correct since I haven't tested it, but I think that's the idea.