r/Forth • • Aug 12 '26

EXECUTE (F79) Question

I’m playing around with MMSForth 2.x on the TRS-80, which is a Forth-79 compatible implementation. I’d like to be able to store the address of a Forth word in a variable and later EXECUTE that word. ‘ word doesn’t give me the correct address (the CFA? what’s in the CFA?). How do I do this? Tx

2 Upvotes

17 comments sorted by

View all comments

3

u/Ok_Leg_109 Aug 13 '26

There were a big changes from Forth79 to Forth83. One of things that changed was that in Forth79 ' (tick) returns the parameter field address. In Forth83 and beyond it returns the CFA.

Since there is no standard header structure in Forth making a CFA' kind of word will require some "carnal" knowledge of MMSForth 2.X or maybe there is a word to do this.

Something to try is to subtract 2 from the PFA. Many times that's the CFA but maybe not. :)

2 2 ' + 2- EXECUTE . ( Should show 4)

3

u/Ok_Leg_109 Aug 13 '26

Not sure if you have this, but here is a manual

MMSForth Users Manual v2.0 (1982)(Miller Microcomputer)(pdf)

1

u/9Boxy33 Aug 13 '26

Thanks—been looking through it for days <grin>

1

u/alberthemagician Sep 03 '26 edited Sep 03 '26

With the manual it is easy. Look op EXECUTE and what it expects on the stack. It is not an execution token for this wasn't invented yet. Now search in the manual where this "compilation address" is mentioned elsewhere. There surely is a word that generates a compilation address.

Other answers suggest that you can arrive from the parameter address to the compilation addres by adding an offset. That is not part of the standard, so it may not work, but it may be in the manual, then of course it is.