User Tools

Site Tools


base:16-bit_absolute_comparison

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
base:16-bit_absolute_comparison [2020-10-22 03:37] – created skatebase:16-bit_absolute_comparison [2020-10-22 16:37] – [Skate & Eins Method] tww
Line 2: Line 2:
 ===== Skate & Eins Method ===== ===== Skate & Eins Method =====
 N1 = 16-bit signed number at zeropage N1 = 16-bit signed number at zeropage
 +
 N2 = 16-bit signed number at zeropage N2 = 16-bit signed number at zeropage
  
Line 48: Line 49:
 endOfAbsCompare: endOfAbsCompare:
 </code> </code>
 +
 +TWW method including the zero flag:
 +
 +<code>
 +/*! «»«»«»«»{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
 +
 +
 +</code>
 +
 +
 +
 +
 +
  
base/16-bit_absolute_comparison.txt · Last modified: 2020-10-22 20:31 by tww