Skip to content

exit is not required to be a primitive. #6

@crcx

Description

@crcx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions