A83: Re: regarding jr nc, $+x


[Prev][Next][Index][Thread]

A83: Re: regarding jr nc, $+x




No.  The $ symbol refers to the address where the opcode starts, so you end
up with the address at the end of the instruction.  To compute the value for
the relative jump, it will subtract that address plus the size of the
opcode, or $+2, giving you 0.  A relative jump of 0 is essentially a nop.
"jr 2" would be correct, except that would be computed as an absolute
address, and not a relative one, which would (most likely) result in the
relative jump being out of range.  You need $+4.  But there's an easier way:
use labels :)

> Is this correct?
>
> jr nc, $+2
> ld b,24
> ;code proceeds here if no carry





References: