Difference between revisions of "SWAP"
m |
|||
Line 9: | Line 9: | ||
<tr><td>Output Flags</td><td>[[Sign Flag]], [[Zero Flag]]</td></tr> | <tr><td>Output Flags</td><td>[[Sign Flag]], [[Zero Flag]]</td></tr> | ||
</table><br/> | </table><br/> | ||
− | The Swap Bytes (SWAP) instruction can perform two very different functions depending on the "double swap" indicator. A single swap trades the lowest eight bits in a register with the upper eight bits. A double swap essentially copies the lowest eight bits in a register to the upper eight bits. Regardless of which swap is specified, the CP1610 then sets or clears the [[Sign Flag]] and [[Zero Flag]] according to the resulting value. The number of clock cycles used depends on the type of swap specified. A single swap will use 6 clock cycles and a double swap will use 8 clock cycles. The opcode format is as follows.<br/> | + | The Swap Bytes (SWAP) instruction can perform two very different functions depending on the "double swap" indicator. A single swap trades the lowest eight bits in a register with the upper eight bits. A double swap essentially copies the lowest eight bits in a register to the upper eight bits. Regardless of which swap is specified, the CP1610 then sets or clears the [[Sign Flag]] and [[Zero Flag]] according to the resulting value. The number of clock cycles used depends on the type of swap specified. A single swap will use 6 clock cycles and a double swap will use 8 clock cycles.<br/><br/> |
+ | |||
+ | [[Image:Swap_diagram.png]] | ||
+ | |||
+ | |||
+ | The opcode format is as follows.<br/><br/> | ||
0000:0000:0100:1srr<br/> | 0000:0000:0100:1srr<br/> |
Revision as of 14:57, 8 October 2007
Instruction Name | Swap Bytes |
Mnemonic | SWAP |
CP1610 Clock Cycles | 6 or 8 |
Interruptible | No |
Opcode Range | $0040-$0047 |
Input Flags | None |
Output Flags | Sign Flag, Zero Flag |
The Swap Bytes (SWAP) instruction can perform two very different functions depending on the "double swap" indicator. A single swap trades the lowest eight bits in a register with the upper eight bits. A double swap essentially copies the lowest eight bits in a register to the upper eight bits. Regardless of which swap is specified, the CP1610 then sets or clears the Sign Flag and Zero Flag according to the resulting value. The number of clock cycles used depends on the type of swap specified. A single swap will use 6 clock cycles and a double swap will use 8 clock cycles.
The opcode format is as follows.
0000:0000:0100:1srr
where: s indicates the type of swap such that: s == 0 indicates a single swap s == 1 indicates a double swap
rr indicates the target register such that: rr == 00 indicates register R0 rr == 01 indicates register R1 rr == 10 indicates register R2 rr == 11 indicates register R3