ld hl,name1_string ;first string
ld bc,(256*20)+2 ;column 2...row 20
ld (_penCol),bc
call _vputs ;print
ld hl,name2_string ;second string
ld bc,(256*27)+2 ;column 2...row 27
ld (_penCol),bc
jp _vputs ;print & exit
name1_string: .db "Running",0
name2_string: .db "Stupid",0
There are two errors in this. For the first one, you wouldn't
be able to see it if you hadn't looked at the
opcode list to see that
ld (arg1),bc takes up 4 bytes where as ld
(arg1),hl only takes up 3. If you wait a second to
load hl with the string address, you can use hl to
set up the cursor coordinates, thus saving one byte. Speed really
isn't a factor here, but, for every one less byte the processor
has to read in your code, it is a little faster. We can't
use hl to save this byte for our second string because, as I will
explain in the second error, hl is holding the address of our
second string. The second error comes
when you load hl with the address of the second string. You
don't have to do this after the last _vputs . After
_vputs is done, hl is at the address of the
byte after the zero terminate which, in this case, is the first
letter of our second string.
| ld hl,(256*20)+2
ld (_penCol),hl
ld hl,name1_string ;first string
call _vputs ;print
ld bc,(256*27)+2 ;column 2...row 27
ld (_penCol),bc
jp _vputs ;print & exit
name1_string: .db "Running",0
name2_string: .db "Stupid",0
| |