Page 1 of 1
[96.1] VERY simple question
Posted: Sat Feb 03, 2001 2:56 pm
by Konan555
Hi,
Just need to find out very quickly how backward Branching is represented in the program.
Is it two's complement or Sign and magnitude?
Thanks
Konan
[96.2] VERY simple question
Posted: Sat Feb 03, 2001 10:35 pm
by Ross Archer
All signed arithmetic on the 6502, including
relative branch calculations, are Two's Complement.
I don't have an assembler handy to prove this, but
vaguely remember than an offset of 0 means the
instruction following the end of the branch statement,
because the PC has already incremented to point to the
next instruction before the offset is added if branch
is taken.... so something like:
HERE: BNE HERE
THERE:NOP
the offset for HERE would be -2 (FE), and BNE THERE
would be 0.
Hope this helps and isn't too wrong.
-- Ross
[96.3] VERY simple question
Posted: Sun Feb 04, 2001 6:12 am
by GARTHWILSON
> Hope this helps and isn't too wrong.
It's right. It would assemble D0 FE and D0 00.