Re: A86: djnz, jr and jp
[Prev][Next][Index][Thread]
Re: A86: djnz, jr and jp
At 18:30 1999-01-08 -0800, you wrote:
>despite all this choas and crap...I'm quite interested now to know if
>ANYONE knows how to use jp/jr/djnz when programming in hex.
jr and djnz uses relative addresses:
$D748 ld b,3 2 bytes
$D74A <do something>
.
.
.
$D75A djnz -$10 2 bytes (loop to $D74A)
The second byte of the last instruction should be -$12 though,
because the relative address is added to PC after the instruction
has been read. Thus, PC is $D75C when djnz has been read,
and -$12 ($EE) is use.d
jr works the same way...
jp uses absolute addressing which mean you have to know the exact
location of where to jump:
$D748 <lots of code>
$D7A0 jp $D758 ; stored as $C3 $58 $D7
When programming in hex, you shouldn't insert code... rather, you will up
a lot of memory with $00 (nop) and overwrite code all the time, so you
don't have to change the jump addresses all the time.
--
Real name: Jimmy Mårdell
Email: mailto:yarin@acc.umu.se
Homepage: http://www.acc.umu.se/~yarin/
Icarus Productions homepage: http://icarus.ganymed.org/
References: