Difference between revisions of "CMP"

From Intellivision Wiki
Jump to: navigation, search
 
m
Line 9: Line 9:
 
<tr><td>Output Flags</td><td>[[Sign Flag]], [[Zero Flag]], [[Overflow Flag]], [[Carry Flag]]</td></tr>
 
<tr><td>Output Flags</td><td>[[Sign Flag]], [[Zero Flag]], [[Overflow Flag]], [[Carry Flag]]</td></tr>
 
</table><br/>
 
</table><br/>
The Compare (CMP) instruction is functionally identical to the [[Subtract]] instruction except that it does not store the resulting value in the destination register. The Compare instruction subtracts the value at the specified address from the value in the specified destination register and sets or clears the [[Sign Flag]], [[Zero Flag]], [[Overflow Flag]], and [[Carry Flag]] according to the result, but the final result is not stored in the destination register, leaving the register unchanged.<br/>
+
The Compare (CMP) instruction is functionally identical to the [[SUB|Subtract]] instruction except that it does not store the resulting value in the destination register. The Compare instruction subtracts the value at the specified address from the value in the specified destination register and sets or clears the [[Sign Flag]], [[Zero Flag]], [[Overflow Flag]], and [[Carry Flag]] according to the result, but the final result is not stored in the destination register, leaving the register unchanged.<br/>
  
 
     Format - Decle #1    Format - Word #2
 
     Format - Decle #1    Format - Word #2

Revision as of 16:51, 17 January 2005

Instruction NameCompare
MnemonicCMP
CP1610 Clock Cycles10
InterruptibleYes
Opcode Range$0340-$0347
Input FlagsNone
Output FlagsSign Flag, Zero Flag, Overflow Flag, Carry Flag

The Compare (CMP) instruction is functionally identical to the Subtract instruction except that it does not store the resulting value in the destination register. The Compare instruction subtracts the value at the specified address from the value in the specified destination register and sets or clears the Sign Flag, Zero Flag, Overflow Flag, and Carry Flag according to the result, but the final result is not stored in the destination register, leaving the register unchanged.

   Format - Decle #1    Format - Word #2
   0000:0011:0100:0rrr  aaaa:aaaa:aaaa:aaaa
where: rrr indicates the destination register such that: rrr == 000 indicates register R0 rrr == 001 indicates register R1 rrr == 010 indicates register R2 rrr == 011 indicates register R3 rrr == 100 indicates register R4 rrr == 101 indicates register R5 rrr == 110 indicates register R6 rrr == 111 indicates register R7
aaaaaaaaaaaaaaaa indicates the source address