COMPARE
Compare the two operands and set the flags.
| Opcode | Bytes | Cycles | Form | Example |
|---|---|---|---|---|
| $95 | 3 | 2 | COMPARE B:_, {BYTE} | COMPARE B:1, 123 |
| $96 | 3 | 2 | COMPARE P:_, {S_BYTE} | COMPARE P:2, 123 |
| $D7 | 4 | 2 | COMPARE P:_, {PAIR} | COMPARE P:2, 12345 |
| $97 | 3 | 2 | COMPARE I:_, {S_BYTE} | COMPARE I:4, 123 |
| $D8 | 4 | 2 | COMPARE I:_, {S_PAIR} | COMPARE I:4, 12345 |
| $98 | 3 | 2 | COMPARE I:_, XHEX {XINT} | COMPARE I:4, XHEX $D000_0000 |
| $99 | 3 | 2 | COMPARE B:_, B:_ | COMPARE B:1, B:2 |
| $9A | 3 | 2 | COMPARE P:_, P:_ | COMPARE P:2, P:4 |
| $9B | 3 | 2 | COMPARE I:_, I:_ | COMPARE I:4, I:8 |
| Condition flag | Output |
|---|---|
| zero (ZF) | If the difference is zero, this flag is 1; otherwise it is 0. |
| negative (NF) | If the signed difference is a negative number, this flag is 1; otherwise it is 0. |
| overflow (OF) | If the difference exceeds the register's signed range, this flag is 1; otherwise it is 0. |
| carry (CF) | If the difference exceeds the register's unsigned range, this flag is 1; otherwise it is 0. |
Notes
-
The flag outputs are calculated exactly the same as for the SUBTRACT instruction, including the effects of the WITH CARRY instruction.
-
COMPAREis typically followed by IF which acts according to the flags.