Re: [stella] 6502 question

Subject: Re: [stella] 6502 question
From: emooney@xxxxxxxxxxxxxxxx (Erik Mooney)
Date: Sat, 05 Apr 1997 01:18:01 GMT
>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.

>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.  BCC is the equivalent of the Intel instruction
JA (jump if above) and BCS is the equivalent of Intel JBE (jump if below or
equal.)  Just translating these into a language I understand =)  Intel
chips have 31 conditional jump instructions (some identical like JE and JZ
which match BEQ) so adjusting to the eight on the 6502 is a little
difficult =)

>Sometimes you will see BPL or BMI.  This branches if the answer has bit
>7 set, i.e. is >= #$80.  Numbers with the most significant bit set are
>considered to be negative numbers in twos-complement.

And zero is considered positive for the purposes of BPL.. that confused me
briefly.  BPL and BMI essentially do signed comparisons on the numbers,
right?  above example, the result is 15 with carry clear, so a BPL would
branch meaning A>X, correct.  And BPL matches Intel's JGE and BMI matches
JL.

>>No ZP,Y?  My reference says there is and I've used it a number of times
>>already.. I guess DASM already adjusted it to Absolute,Y for me.
>
>My reference says there isn't.  You can find out by marking that instruction
>with a label and finding out where that label wound up on the assembly,
>perhaps like this:

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..)

--
Archives available at http://www.biglist.com/lists/stella/archives/
E-mail UNSUBSCRIBE in the body to stella-request@xxxxxxxxxxx to be removed.

Current Thread