DJNZ displacement

Hi

I had a question about DJNZ operation.

Just running through this code in MMCOYZXS by Toni Baker page's 87-88

21A440 LD HL,40A4
11083F LD DE,3F08
0608 LD B,08
1A LOOP LD A,(DE)
77 LD (HL),A

24 INC H 13 INC DE
10FA DJNZ LOOP
C9 RET

=========== another format with addressing ======
fa00: 21 a4 40 ld hl, $40a4
fa03: 11 08 3f ld de, $3f08
fa06: 06 08 ld b, $08
fa08: 1a ld a, (de)
fa09: 77 ld (hl), a
fa0a: 24 inc h
fa0b: 13 inc de
fa0c: 10 fa djnz $fa0

(my program starts running at 0xFA00)



In regards to the 10FA DJNZ operation, from what I gather the displacement is negative 0x6 I think; which takes me to 0xFA06 in my code which then executes from 0xFA08

I am unsure how it calculates back negative 6. Does it include the 2 bytes of 10FA DJNZ?

Thanks
Post edited by username on

Comments

  • edited April 2014
    After reading the DJNZ instruction, the program counter is already pointing to the next instruction (the RET) - so you have to count forwards or backwards from there.
    Joefish
    - IONIAN-GAMES.com -
  • edited April 2014
    Thanks
Sign In or Register to comment.