User Tools

Site Tools


base:16-bit_comparison

Differences

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

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
base:16-bit_comparison [2020-10-22 20:30] – created twwbase:16-bit_comparison [2020-10-24 14:05] – [TWW Method] verz
Line 17: Line 17:
  
     lda val1     lda val1
-    sec +    ;sec 
-    sbc val2+    ;sbc val2 
 +    cmp val2
     php     php
     lda val1+1     lda val1+1
Line 26: Line 27:
     sta temp     sta temp
     pla     pla
-    and #%00000010+    ;and #%00000010  ; useless because of the following ORA
     ora #%11111101     ora #%11111101
     and temp     and temp
Line 42: Line 43:
  
  
 +Different approach: instead of setting flags, goes to different destinations:
  
 +<code>
 +; Val1 ≥ Val2 ?
 +  LDA Val1 +1    ; high bytes
 +  CMP Val2+1
 +  BCC LsThan     ; hiVal1 < hiVal2 --> Val1 < Val2
 +  BNE GrtEqu     ; hiVal1 ≠ hiVal2 --> Val1 > Val2
 +  LDA Val1       ; low bytes
 +  CMP Val2
 +  ;BEQ Equal     ; Val1 = Val2
 +  BCS GrtEqu     ; loVal1 ≥ loVal2 --> Val1 ≥ Val2
 +LsThan
 +...
 +GrtEqu
 +...
 +</code>
  
  
base/16-bit_comparison.txt · Last modified: 2021-09-13 17:23 by tww