Subject: Re: [stella] 6502 questions From: Thomas Jentzsch <tjentzsch@xxxxxx> Date: Thu, 11 Oct 2001 19:22:09 +0100 |
Ben Larson wrote: > OK I am seriously confused as to the how the compare > and branch instructions work. Ok first of all, > correct me if I am wrong, but when you do a BPL > doesn't that check to see if the value you are > comparing is greater than the the value in the > accumulator? A compare works like a subtraction (like SBC, but without the carry influence): - N-flag: set, when the subtracted signed value is bigger, so the result is negative (signed compare) - C-flag: set, when the subtracted unsigned value is bigger (unsigned compare) - V-flag: set, when there is an signed overflow in subtraction (i.E. -128 - 1 and +127 - -1) (signed compare) > Well if that's so, then is the processor > comparing the two numbers as unsigned 8-bit integers > or signed? In other words, what would be the outcome > of, say...this: > LDA #100 > CMP #-20 ; -20 signed = 236 unsigned > BPL AIsLess ; in a 2's comp. representation - 100 is bigger than -20 (or: the result is 120 = $78, that's positive), so the N-flag is clear. - 236 is bigger than 100, so the C-flag is set, - there was no signed overflow (100- -20 = 120), so the V-flag is clear. Have fun! Thomas _______________________________________________________ Thomas Jentzsch | *** Every bit is sacred ! *** tjentzsch at web dot de | - Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[stella] 6502 questions, Ben Larson | Thread | Re: [stella] 6502 questions, Chris Wilkson |
Aw: Re: [stella] 6502 questions, cybergoth | Date | Re: [stella] 6502 questions, Chris Wilkson |
Month |