this kind of stems of gbz80 - IF statements
I have a code that loops 0x167 times, writing to the screen. What I'd like to happen is for the script to loop three times.
My script:
d322 21A0C3 LD HL,C3A0h
d323 016801 LD BC,0168h
d324 110300 LD DE,0003h
d325 00 NOP
.
.
.
d330 0B DEC BC
d331 75 LD (HL),L
d332 00 NOP
d333 23 INC HL
d334 00 NOP
.
.
.
d33f 78 LD A,B
d340 B1 OR C
d341 C22BD3 JP NZ,D32Bh
d344 7A LD A,D
d345 B3 OR E
d346 1B DEC DE
d347 00 NOP
d348 00 NOP
d349 C22BD3 JP NZ,D32B
d34c C9 RET
Now, instead of stopping where it should, it goes on to corrupt memory further until it reaches d325 and causes the script to crash. As you might be able to tell, I attempted to use DE as the counter for loops.
Please explain your answer, I'm still quite dull towards this.