[96] VERY simple question

Prior to establishing the forum directly on 6502.org, we had a forum hosted on DelphiForums. This read-only category is a complete archive containing all of the posts from our old forum.
Locked
Konan555

[96.1] VERY simple question

Post 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
Ross Archer
Posts: 6
Joined: 10 Oct 2002
Location: San Jose, CA
Contact:

[96.2] VERY simple question

Post 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
The economy isn't "Grapes of Wrath", but it is getting
to be "Raisins of Regret."

-- Ross
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

[96.3] VERY simple question

Post by GARTHWILSON »

> Hope this helps and isn't too wrong.

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?
Locked