Re: A86: loops
[Prev][Next][Index][Thread]
Re: A86: loops
Mark,
The JR instructions are all two bytes long. The displacement is calculated
from the byte FOLLOWING the instruction. It's a 1-byte signed (two's
complement) value. Anyway, a simple loop would look like this:
D748 06 0A ld b,10
D74A 3E 00 ld a,1
D74C loop:
D74C 3C inc a
D74D 10 FD djnz loop ;offset is (D74F-D74C = -3 or FD)
D74F C9 ret ;or (offset djnz (or jr) instr+2)-(loop)
This will count a from 1 to 10. Hope this helps...
--Joshua
References:
- A86: loops
- From: Mark Baldi-Biek <baldi@lclark.edu>