Re: [stella] 6502 questions

Subject: Re: [stella] 6502 questions
From: Erik Mooney <erik@xxxxxxxxxx>
Date: Thu, 11 Oct 2001 12:15:22 -0400
10/11/2001 11:24:45 AM, Ben Larson <wazzapfool@xxxxxxxxx> 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? 

Recall that in assembly language, branch instructions merely check the value
of the CPU flags; they don't really perform a 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
>AIsNotLess

BPL branches if the MINUS flag is not set.  CMP sets the MINUS flag according
to the 8th bit of the result.  So, since the result of that CMP is 80 decimal, the top
bit is not set, the MINUS flag is not set, and BPL won't branch.

Try Nick Bensema's explanation of 6502 math here:

http://www.biglist.com/lists/stella/archives/199704/msg00032.html



-
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread