Assembler Macros

There are quite a few macros that we use in the assembly part of the source. Several of these are used for readability reasons. A few are used to build the initial dictionaries. If you intend to work on the core you need to understand these.

upsh

Push a value to the data stack

upop

Pop a value from the data stack

drop

DROP the TOS

dup

DUPlicate the TOS

code

Add a new Forth word

mcode

Add a new compiler macro

next

End a definition

var

Add a new variable

inline

Inline some bytes

fdef

Creates a Forth-vocabulary dictionary for a colon entry (new as of 8.0)

mdef

Creates a Macro-vocabulary dictionary for a colon entry (new as of 8.0)

vdef

Creates a Forth-vocabulary dictionary for a variable (new as of 8.0)

upsh and upop

Use upsh and upop to place or obtain the values of memory locations, registers, and integer values on the stack. dup and drop are like the Forth primitives.

var, code, and mcode

Using code and mcode is slightly more difficult:

code 'forthname', assemblyname
mcode 'forthname', assemblyname
var 'forthname', assemblyname, value

Use next in place of RET for readability.

fdef, mdef, and vdef

As of RetroForth 8.0, word headers are no longer kept in the same code space as the definition contents. Therefore, when coding new assembly language primitives, it is not sufficient to just use var, code, or mcode macros. You must also update the core.dict file with corresponding fdef, mdef, or vdef macro invokations, to provide the proper dictionary linkage. The syntax for each is as follows:

fdef 'forthname', assemblyname
mdef 'forthname', assemblyname
vdef 'forthname', assemblyname