Published at October 22, 2020 · 9 min read
So lets start where we ended in part 3. We had a piece of code which printed a letter, one by one, to the screen to finally print “Hello world”.
Execute:
LD HL, HELLO
LOOP: LD A, (HL)
CP 0
RET Z
CALL CHPUT
INC HL
JP LOOP
HELLO: db "Hello world",0
First we point register pair HL to the label HELLO. On that label we define a set of bytes (db) in memory, “Hello world”. Effectively, HL now contains the memory adress of the capital H. INC HL will increase HL so it will point to the next byte in memory, containing the letter e. Now what will happen if we use INC (HL) instead?