sectorforth icon indicating copy to clipboard operation
sectorforth copied to clipboard

`exit` is not required to be a primitive.

Open crcx opened this issue 3 years ago • 0 comments

the following code manipulates the return stack to cause the caller of exit to, uhm, exit:

: exit>> rp@ @ \ the return address points to semicolon rp@ 2 + ! \ replace caller of exit with return to semicolon ; : exit exit>> ; \ exit>> returns twice to this semicolon

naturally the machine code to pop si from bp still needs to exist, and semicolon lays down a pointer to it at the end of a definition, but it is not required to be a named sectorforth primitive word.

this reduces the number of primitives needed to build a functioning forth to seven.

crcx avatar Feb 04 '22 12:02 crcx