User Tools

Site Tools


base:16-bit_comparison

This is an old revision of the document!


16-Bit Comparison

TWW Method

TWW method:

/*! «»«»«»«»{CMP16}«»«»«»«»
    Does exactly the same as CMP of two values (effectively its a val1-val2) and sets the flags as follows:

                       (BCC/BCS)      (BEQ/BNE)      (BMI/BPL)
    If val1 = val2 : Carry =  SET   Zero =  SET   Negative = CLEAR
    If val1 > val2 : Carry =  SET   Zero = CLEAR  Negative = CLEAR
    If val1 < val2 : Carry = CLEAR  Zero = CLEAR  Negative =  SET
*/

    lda val1
    sec
    sbc val2
    php
    lda val1+1
    sbc val2+1
    php
    pla
    sta temp
    pla
    and #%00000010
    ora #%11111101
    and temp
    pha
    plp


Somewhere on ZP:
temp:
    .byte $00

base/16-bit_comparison.1603391443.txt.gz · Last modified: 2020-10-22 20:30 by tww