sectorforth
sectorforth copied to clipboard
`exit` is not required to be a primitive.
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.