06-18-2010, 03:29 PM
CLS and PRINT routine both uses LD HL, SCREEN_ADDRESS. CLS have LD HL, SCREEN ADDRESS. PRint uses LD HL,(SCREEN_ADDRESS) by reading into CLS's routine. This way:
One might think that this scheme should be reversed so LD HL, SCREEN_ADDRESS goes in print routine (CLS is less frequently used). But this will require to include PRINT (a long routine) even if PRINT instruction is not used. So goes to CLS (much much shorter). See cls.asm and print.asm source codes in librar-asm if you like (PRINT needs some rearrangement).
Code:
CLS:
SCREEN_ADDRESS EQU XXXX + 1
XXXX:
LD HL, 16384 ; Defaults to 16384
...
...
PRINT:
LD HL, (SCREEN_ADDRESS)