The following is a part of NYYRIKKI's HelloWorld code. I have some questions on NMI related routines. Please see the routine in bold. I would like to understand this.
I guess that probably the program tried to avoid NMI. Whenever "JR OVERNMI" is executed, it jumps over to "OVERNMI: DJNZ..." until B becomes Zero. So it would never execute the rest of commands including NOP, NOP, RETN in COPYORDER. Why did the author put some commands which would not be executed eventually? is it possible to replace "JR OVERNMI" and the rest ones with just "DJNZ COPYORDER" ?
Anyway, could anybody explain about why the code is written like this?
...
;----------------------------------------------------------
; Let's set write address to start of name table
XOR A
OUT 99h,A
LD A,40h
OUT 99h,A
; Let's put characters to screen
LD HL,ORDER
LD B,ORDER_END-ORDER
COPYORDER:
LD A,(HL)
OUT 98h,A
INC HL
JR OVERNMI
NOP
NOP
; Here is address #66, that is entry for NMI
RETN ;Return from NMI
OVERNMI:
DJNZ COPYORDER
; The end
HALT
; Character set:
; --------------
ORDER:
DEFB 1,2,3,3,4,0,5,4,6,3,7
ORDER_END:
CHARS:
; H
DEFB %11111000
DEFB %10001000
DEFB %10001000
DEFB %11111000
DEFB %10001000
DEFB %10001000
DEFB %11111000
DEFB %00000000
...