Code: Select all
.WORD STAR ; *
.WORD $4000 ; LO
.WORD PLUS ; +
Code: Select all
.WORD STAR ; *
.WORD LIT
.WORD $4000 ; LO
.WORD PLUS ; +
Also, IF doesn't end up in the target word as ".WORD IF". It's an immediate word that compiles a ZBRAN (0BRANCH in the FIG glossary = BRANCH if top item on stack is ZERO) to $0000 and ELSE or ENDIF goes back and fills in the $0000 with the correct offset).
How do you tell if a word is immediate and will need this special treatment? Look in the assembly at each word and if the very first byte (before the name) has a "C" in the upper nybble it is immediate and you'll need to figure out what it does and put the result in your RSLW. If the upper nybble is an "8" then it's not an immediate word and you can just put it in your RSLW with ".WORD".
I think IF and ENDIF are the only two you have here that are immediate, and you can use labels in the assembly so you can just put "MYLABEL-^" (for where to go if it's FALSE - MYLABEL should go where the ENDIF is now) right after the ZBRAN. The ^ is the "current assembling address" for my assembler - yours may use a different symbol. The literal after ZBRAN is added to the Forth IP to take the branch, so it needs to be an offset (positive or negative) rather than an absolute location. You can look at some of the other assembly code to see it used. Sometimes they did the math in the assembly and sometimes they just hardcoded the offset.
One last note - it looks like you missed the R> just in front of the IF. That will also cause crashes.
So you are on the right track, but there are more little details that need to be taken care of to get your RSLW to be a valid FIG Forth word.