To load the ASSEMBLER vocabulary I usually give
NEEDS ASSEMBLER
or, using the old fashion blocks way
100 LOAD
that in turn, loads many screens between 100 and 160.
A new ASSEMBLER vocabulary is created so you can CODE directly in Z80 Assembler, with a custom Forth-like notation though.
For example (see Screen # 291 and 292, giving 291 LIST ):
FORTH DEFINITIONS HEX
CODE GREY-SCREEN
PUSH BC|
LDX HL| 4000 NN,
LDX DE| AA55 NN,
LDX BC| 000C NN,
HERE
HERE
LD A'| (HL)|
XORA E|
LD (HL)'| A|
INCX HL|
DJNZ BACK,
HERE
LD A'| (HL)|
XORA D|
LD (HL)'| A|
INCX HL|
DJNZ BACK,
JRF NZ'| BACK,
POP BC|
NEXT
C;
The above Forth listing creates a new word GREY-SCREEN that XORs whatever is on Layer-0 screen with a checkered-pixel pattern.
You will notice how the Assembler notation is slightly different from the usual. This is due to avoid Vocabulary conflicts, both op-codes and arguments that have often specialized, e.g. LDX HL| n NN, to load HL register-pair, or INCX HL| to increment it. There is almost no need for labels and DJNZ loops can be enclosed by HERE ... BACK, to resolve the displacement.
In any case, BC register-pair must be preserved since it contains the current Forth Instruction-Pointer. Also IY since it is used in standard ROM calls. All other registers can be used.
In this Forth implementation I carefully avoided the use of alternate registers, unless interrupts are disabled. This allows fast-switch context using EXX for an Interrupt Routine - in the future.
I have to write a separate document for the ASSEMBLER vocabulary. Still, you can find some clues by reading the complete source available under ./SRC directory. Also screens # 150 to # 159 provide some test examples.
In this table:
You can use (IX+ operand wherever you can use (IY+ operand.
N.B. : in Forth spaces matter.: