NEGR

From Intellivision Wiki

(Difference between revisions)
Jump to: navigation, search
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 Negate Register (NEGR) instruction creates a twos complement of the value in the specified register, stores the result in the same register, and sets or clears the [[Sign Flag]], [[Zero Flag]], [[Overflow Flag]], and [[Carry Flag]] according to the results. Note that a twos complement of any 16-bit value is equivalent to the value xor'ed with $FFFF and then adding one (1) to the result ((value^$FFFF)+1).<br/>
+
The Negate Register (NEGR) instruction creates a 2s complement of the value in the specified register, stores the result in the same register, and sets or clears the [[Sign Flag]], [[Zero Flag]], [[Overflow Flag]], and [[Carry Flag]] according to the results. The machine computes the 2s complement by inverting the number (e.g. XOR it with $FFFF) and then adding one (1) to the result ((value^$FFFF)+1).  Negating 0, for instance, sets the [[Carry Flag]].<br/>
     0000:0000:0010:0rrr<br/>
     0000:0000:0010:0rrr<br/>

Revision as of 19:36, 12 January 2005

Instruction NameNegate Register
MnemonicNEGR
CP1610 Clock Cycles6
InterruptibleYes
Opcode Range$0020-$0027
Input FlagsNone
Output FlagsSign Flag, Zero Flag, Overflow Flag, Carry Flag

The Negate Register (NEGR) instruction creates a 2s complement of the value in the specified register, stores the result in the same register, and sets or clears the Sign Flag, Zero Flag, Overflow Flag, and Carry Flag according to the results. The machine computes the 2s complement by inverting the number (e.g. XOR it with $FFFF) and then adding one (1) to the result ((value^$FFFF)+1). Negating 0, for instance, sets the Carry Flag.

   0000:0000:0010:0rrr
where: rrr indicates the target 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
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox