Subject: Re: [stella] signed 8-bit comparisons? From: "Eric Ball" <ericball@xxxxxxxxxxxx> Date: Thu, 4 Mar 2004 15:50:28 -0500 |
> That seems to work. I don't need to clear carry or anything. > (Oh. I see there is no "clear minus" instruction anyway. > I guess the LDA will always set that, but not the carry. > I guess a sharper 6502 programmer would know that pretty > much instantly...) Yes, any LoaD instruction (including register to register transfers like TYA, though maybe not PLA) will update the N & Z flags. A CoMPare instruction sets the flags just like register + ~memory + 1 (Carry flag ignored) So if A = $00 then CMP #$00 is the same as $00 + ~$00 + 1 = $00 + $FF + 1 = $100 So Carry = 1 because the result is more than 8 bits, Zero = 1 because the 8 bit result is $00, and Negative (aka Sign) = 0 because the result AND $80 is $00. (Note: CoMPare does not change the oVerflow flag; which is changed by only ADC, SBC and BIT.) ---------------------------------------------------------------------------------------------- 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 -> |
---|---|---|
Re: [stella] signed 8-bit compariso, KirkIsrael | Thread | Re: Re: [stella] signed 8-bit compa, Dennis Debro |
Re: [stella] JoustPong: feedback pl, KirkIsrael | Date | Re: Re: [stella] signed 8-bit compa, Dennis Debro |
Month |