I am trying to use CMP to compare a value stored in a stack frame with a character.
I have have done this but I keep getting invalid addressing mode. The only time i have got it to work is by storing 'B' into a data register. But the subroutine this is in has to be transparent as it is part of the activity, so I can't modify data registers.
CMP.B -1(A6),#'B'
I have also tried storing 'B' into the stack frame and doing
CMP.B -1(A6),-2(A6)
But this also gives invalid addressing mode. Please let me know any solutions that can keep the subroutine transparent.
The second operand of the
CMPinstruction needs to be a data register. Alternatively,CMPAtakes an address register as second operand, orCMPItakes an immediate value as first operand. That means, you could write:Many assemblers will likely also accept
cmp.b #'B',-1(A6)and translate it to aCMPIinstruction.