From Intellivision Wiki
m (Protected "SWAP" ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite)))
Revision as of 09:16, 4 December 2010
|Instruction Name||Swap Bytes|
|CP1610 Clock Cycles||6 or 8|
|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 Sign Flag gets set based on bit 7 of the result. This makes double-swap useful for testing the sign bit of an 8-bit 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.
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