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] VERY simple question
-
Ross Archer
- Posts: 6
- Joined: 10 Oct 2002
- Location: San Jose, CA
- Contact:
[96.2] VERY simple question
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
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
The economy isn't "Grapes of Wrath", but it is getting
to be "Raisins of Regret."
-- Ross
to be "Raisins of Regret."
-- Ross
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
[96.3] VERY simple question
> Hope this helps and isn't too wrong.
It's right. It would assemble D0 FE and D0 00.
It's right. It would assemble D0 FE and D0 00.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?