Skip to content

Execution token is address#14

Open
nickd4 wants to merge 47 commits intouho:masterfrom
nickd4:xt_is_address
Open

Execution token is address#14
nickd4 wants to merge 47 commits intouho:masterfrom
nickd4:xt_is_address

Conversation

@nickd4
Copy link

@nickd4 nickd4 commented Apr 30, 2022

Since initially coming to preForth, the execute word has bothered me a bit. It takes on the stack an integer token number, then executes the equivalent of h@ to read the corresponding address from the headers table, and then "calls" the defined word at that address (by a tail call). I have wanted to remove the h@ for efficiency reasons, i.e. simply pop an address and execute it.

This required me to undertake an analysis of all calls to hp, h@, h, and token to understand where the integer tokens originate and make sure they are all replaced with addresses. This PR contains the corresponding changes, in summary:

  • After token insert h@ everywhere.
  • Otherwise, remove h@ everywhere, and recode the execute word accordingly.
  • The compile, then becomes a synonym for , so replace that everywhere as well, and move another token down into the spot previously occupied by compile,.
  • Make new and create leave an address rather than a token on the stack, by replacing hp @ here h, with here dup h,.

It works. I think this is more efficient and simpler code. Also, it opens the door to some further improvements that would aim to use the headers table only for communication with the tokenizer, maybe even reclaiming that memory once *.seed is running.

…to bss rather than text section which avoids the need to call mprotect(), rename things
… be wrapped with PROGRAM / END, also removes automatic bye token that was generated by END
…time.seedsource, so that we can run textual forth code without the tests or the banner
… writes to stderr, fix self-hosted tokenizer termination issue (was debugged with eemit)
…ng the nonstandard words on top of gForth's standard words, produces redefinition warnings
…seedForth-i386.pre containing some compiler words so we can do special handling for DTC
…sticated tracing and symbolic debug (via annotated trace) system used to debug the 65C02 port, the trace is also available for the Z80 port and can be used for comparison
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants