base:16-bit_comparison
This is an old revision of the document!
16-Bit Comparison
TWW Method
16 bit equivalent of the CMP OPC:
/*! «»«»«»«»{CMP16}«»«»«»«» Does exactly the same as CMP of two values (effectively its a A - M) and sets the flags as follows: If A = M : Carry = SET Zero = SET Negative = CLEAR If A > M : Carry = SET Zero = CLEAR Negative = CLEAR If A < M : Carry = CLEAR Zero = CLEAR Negative = SET */ lda A+1 cmp M+1 bne !+ lda A cmp M !: // Status register sorted, from here you can branch as you like as you would after a CMP opc.
Different approach: instead of setting flags, goes to different destinations:
; 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 ...
base/16-bit_comparison.1603755257.txt.gz · Last modified: 2020-10-27 00:34 by tww_ctr