DSCF

.co.uK

Macros in PC32

Macros are a handy little function of the language, they allow you to inline code until a return is found(0xC3C3 in x86). Its useful when optimizing for speed and mandatory in certain words such as >R(push) and <R(pop).
Macros can be toggled with the TAB key in the x86 version of the editor.

Why certain words must be inlined?

Often times there are some words that will crash the editor when not inlined, all of those words usually deal with the Return Stack in some manner or another For example the most basic:

>R 50 drp ;

Which does:

>R

Defines the >R word into the dictionary

50

Inlines the opcode for push EAX/TOS into ESP/Rstack

drp

Inlines the word 'drp' as a macro into this definition

;

executes the word ';' which compiles C3C3 into this definition

As you can see this code does very little, but if you were to put it in source as a call then it would crash like so:

123

Pushes 123 into TOS

>R

Call >R

---

Inside >R

50

Pushes 123 into ESP

drp

Drops 123 from data stack

;

Crashes here! Execution finds a return but the top of Rstack is the number 123!