;; Tell the assembler that this is z80 code
.Z80
;; Define system calls to be used
reset EQU 0h
bdos EQU 5h
write EQU 2h ;argument goes in E
writstr EQU 9h ;argument address goes in DE
;; Create constants for the command tail in the zero page
tlength EQU 80h
ctail EQU 81h
;; Get length of command tail
LD HL,tlength ;this is just LD HL,80h
;; Output length of command tail as ASCII symbol
LD E,(HL) ;writes whatever is at 80h into E
LD C,write
CALL bdos ;call write E
;; Mark end of command tail with $
LD HL,tlength ;side effects might have cleared HL
LD C,(HL) ;have to load into 8 bit register
LD B,0;higher byte of BC must be 0
LD HL,ctail ;LD HL,81h
ADD HL,BC;add contents of BC to HL
LD A,'$';"$"
LD (HL),A;write "$" to address in HL
;; Output command tail
LD DE,ctail
LD C,writstr
CALL bdos;call writestr DE
;; Exit
JP reset;jump to 0h
END