I have looked but could not find any assembly code for a 16 bit compare routine. We are using a QG4 part and I need to determine if a 16 bit value is =, <,or >.
there is an 8 bit routine but not sure if can be modified for 16 bits.
Thanks in advance for any help.
The LDHX, CPHX solution is good only for 16-bit, and assumes 9S08 if SP-indexed, and certainly it can not be used with X-indexed operands.
More generic 16-bit (or higher) compares can be done for any addressing mode by using the Accumulator (A) in a series of LDA/CMP/BNE instructions, (the final BNE being redundant), starting from the MSB, like so:
op1 rmb 2
op2 rmb 2
;;;;; bne Skip
; here we can use all comparison branches available, just like after a single CMP instruction.
This method can be turned into a generic macro or subroutine that compares any two 16-bit (or higher) operands regardless of addressing mode. (Care has to be taken when the macro is allowed to compare against immediate mode values to use the related syntax for those cases.)
(Many such macros are available for ASM8 here)