[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'Hello world' for monitor mode and an assembler?



In article <10l1shjhreptu8d@corp.supernews.com>,
 "Laine Houghton" <laine@intergate.com> wrote:
> [...]
> Understanding how the compares work might just make things clearer.
> CMP, CPY, CPX work with the  A,Y and X registers respectively.
> 
> The target of the compare is either a (#)immediate actual value or the value
> of a memory location.
> CMP #$D; is A = to 13
> CMP $D ; is A = to the value stored at memory location 13
> 
> I used equal above but a compare is actually a subtraction.
> CPY #$D is actually... subtract 13 from the value of the Y register.
> No register or memory contents change but the result of the subtraction is
> reflected in three flags. Negative flag, Zero flag and Carry flag.
> 
> register   target
> 12      -  13 = -1   ; N=1  Z=0  C=0
> 13      -  13 =  0   ; N=0  Z=1   C=1
> 13      -  14 =  1   ; N=0  Z=0   C=1
> 
> BMI branch N=1
> BPL branch N=0
> 
> BEQ branch Z=1
> BNE branch Z=0
> 
> BCS branch C=1
> BCC branch C=0
> 
> Also BCC detects register less than target.
>      BEQ detects register equal to target
>      BCS detects register is equal to or greater than target
>      BCS followed by BNE will detect register greater than target

Indeed, some assemblers offer the alternate mnemonics BLT (Branch if 
Less Than) and BGE (Branch if Greater than or Equal) as aliases of 
BCC and BCS, respectively.

-- 
John
----
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/