Subject: Re: [stella] 6502 question|
From: Nick S Bensema <nickb@xxxxxxxxxxxx>
Date: Fri, 4 Apr 1997 21:53:52 -0700 (MST)
>>The general rule is SBC does the exact same thing as ADC but the operand >>is exclusive-or'ed with $FF first. That is why you always see people SET >>the carry bit before subtracting: suppose for some dumb reason you wanted > >Aha.. I figured out by trial and error that SBC did A-value-(NOT carry) >instead of A-value-carry as my reference said and as 80x86 processors do, >but thinking of it this way makes things clearer. That confused me when I was doing software sprites on an atari 8-bit demo I was working on. Some weird bug caused me to abandon it. >>CMP works like SEC+SBC, without changing any registers other than P. >>Therefore, if everything I said above isn't a total load of bull... >> >> LDA #5 >> CMP X >> BCC X_IS_MORE_THAN_FIVE >> BEQ X_IS_EQUAL_TO_FIVE >> BCS X_IS_LESS_THAN_OR_EQUAL_TO_FIVE. > >Are those comparisons signed or unsigned? As in, if X is #$F6 = -10, the >result would be 5+9+1=15, with the carry clear, so the BCC would happen and >the comparison is unsigned. Exactly. >Yeah, I checked my code and DASM was turning it into an Absolute,Y for me >without telling me. Thanks again for all the help. One (well, two) more >questions: what does ADC do to the overflow flag, and how does BIT affect >the flags? (I need a more complete reference..) Duh, I dunno. I think the overflow flag is like the carry bit, but it goes off if the addition surpasses 0x80 (128), not 0x00. But I never use it. -- Archives available at http://www.biglist.com/lists/stella/archives/ E-mail UNSUBSCRIBE in the body to stella-request@xxxxxxxxxxx to be removed.