
The assembly course's S11 printed a message by walking along a string of bytes until it reached a 0. Its strings were written the way z80asm likes them: DEFB 'HELLO ',0. GEN80 does not take that line - and one of the obvious ways of fixing it is a trap. This section rebuilds S11's program and gathers every difference between the two assemblers in one place.
GEN80 has two directives for bytes:
DEFB takes numbers, and characters one at a time: DEFB "H","E",0.DEFM takes one string: DEFM "HELLO ".A string after DEFB is Bad expression. So a z80asm string with its 0 on the end becomes two lines:
MSG1: DEFM "HELLO "
DEFB 0
It is tempting to write that as one line, DEFM "HELLO ",0. GEN80 takes it without a word - and ignores everything after the string. There is no 0. DEFM "AB","CD" is the same: you get AB and nothing else.
The assembler will not tell you. Your program will: a string with no 0 on the end just carries on into whatever comes after it. Try it in Change One Thing below.
A single character is written in double quotes: LD A,"H". In single quotes it is Bad expression. DEFM is the one place single quotes work: DEFM 'HELLO' is the same as DEFM "HELLO". It is simplest to use double quotes everywhere.
PUTS: and PUTS both define a label.MESSAGEPART1 and MESSAGEPART2 are the same label to GEN80 - Redefined symbol.PUTS and Puts are two different labels.ORG needed. Every program starts at 100h. ORG 256 still works but draws a warning, *WARNING* ORGs used: 01. ORG sets the addresses your code is assembled for - it does not move the code within the file, which always starts with your first instruction.*I NAME, starting in the very first column, for a file NAME.GEN on the disc. include 'vdp.asm' is Bad mnemonic, and a *I with spaces in front of it is Symbol is Reserved Word. S8 points you on to splitting a bigger program into files this way.The rest of what you wrote in the assembly course goes through unchanged:
41h, 0FFh, 01000001b - and GEN80 also takes #41 and %01000001$ for the current address, EQU, DEFW (low byte first), DEFS (filled with zeros)* done before + - so the assembly course's 3800h+9*32+12 means what it did - unary minus, and label arithmetic like MSG+1(HL), (IX+5), (4000h), JR and DJNZ to labels, RST 8 or RST 08hS11's program, for GEN80:
; TEXT - THE ASSEMBLY COURSE'S S11
LD HL,MSG1
CALL PUTS
LD HL,MSG2
CALL PUTS
RET
; PRINT THE STRING AT HL, UP TO A 0
PUTS: LD A,(HL)
CP 0
RET Z ; DONE
RST 8
DEFB 158 ; ZOUTC
INC HL
JR PUTS
MSG1: DEFM "HELLO "
DEFB 0
MSG2: DEFM "WORLD"
DEFB 0
Edit, assemble and run
ED80 TEXT.GEN
Type it in, CONTROL-K CONTROL-X, ENTER, then:
GEN80 TEXT
TEXT
What you should see
0:TEXT
HELLO WORLD
0:
MSG1's two lines into one: MSG1: DEFM "HELLO ",0. GEN80 is happy. What does the program print now, and why that?DEFM to DEFB on MSG1's line. What does GEN80 say?MSG1 to MESSAGEPART1 and MSG2 to MESSAGEPART2, everywhere they appear. Which line does GEN80 complain about?ZOUTC EQU 158 near the top, and change DEFB 158 to DEFB ZOUTC. Does anything change when it runs?Strings go in DEFM, one per line, with the 0 on a DEFB of its own; characters go in double quotes; labels are case-sensitive and count 10 characters; no ORG; *I for includes. Almost everything else is as the assembly course wrote it. Appendix II has the whole list on one page.
S7: watching a program from the inside with MON80.