aw / fiveforths

32-bit RISC-V Forth for microcontrollers
https://fiveforths.a1w.ca
MIT License
66 stars 3 forks source link

Fix bug when defining multiple colon words #6

Closed aw closed 1 year ago

aw commented 1 year ago

When defining a colon word which contains other colon words, the codeword definition doesn't seem to point to the correct address. It appears to point to docol in each case, but I think it might need to point to the next memory address right after that (+4).

Example:

: dup sp@ @ ;   ok
: invert dup nand ;   ok
0 invert<??crash??>

Technically this invert should take the top stack value, duplicate it, then uses nand to bitwise AND and NOT the two identical values, thus inverting them, thus giving -1 (or 0xFFFFFFFF).

aw commented 1 year ago

Fixed in dcb87dc