We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

SWAP (Super FX): Difference between revisions

From SnesLab
Jump to: navigation, search
(blurb about specifying sreg/dreg in advance)
(made flags affected more prominent)
 
(5 intermediate revisions by the same user not shown)
Line 26: Line 26:
|[[Sign Flag|S]]
|[[Sign Flag|S]]
|[[CY]]
|[[CY]]
|Z
|[[Zero Flag|Z]]
|+
|+
|0
|0
Line 32: Line 32:
|0
|0
|.
|.
|
|S
|.
|.
|
|Z
|}
|}


'''SWAP''' is a [[Super FX]] instruction that swaps two bytes.  The low byte of the [[source register]] is written to the high byte of the [[destination register]], and the high byte of the source register is written to the low byte of the destination register.  The source register itself is left unchanged.
'''SWAP''' is a [[Super FX]] instruction that swaps two bytes.  The low byte of the [[source register]] is written to the high byte of the [[destination register]], and the high byte of the source register is written to the low byte of the destination register.  The source register itself is left unchanged.
The [[ALT0]] state is restored.


The source and destination registers should be specified in advance using [[WITH]], [[FROM]], or [[TO]].  Otherwise, R<sub>0</sub> serves as the default.
The source and destination registers should be specified in advance using [[WITH]], [[FROM]], or [[TO]].  Otherwise, R<sub>0</sub> serves as the default.
Line 60: Line 62:
* [[XCE]]
* [[XCE]]
* [[XCN]]
* [[XCN]]
* [[MERGE]]


=== External Links ===
=== External Links ===
* Official Nintendo documentation on SWAP: 9.88 on [https://archive.org/details/SNESDevManual/book2/page/n276 Page 2-9-120 of Book II]
* Official Nintendo documentation on SWAP: 9.88 on [https://archive.org/details/SNESDevManual/book2/page/n276 page 2-9-120 of Book II]


[[Category:ASM]]
[[Category:ASM]]
Line 69: Line 72:
[[Category:One-byte Instructions]]
[[Category:One-byte Instructions]]
[[Category:Expects Sreg/Dreg Prearranged]]
[[Category:Expects Sreg/Dreg Prearranged]]
[[Category:Exchange Instructions]]

Latest revision as of 19:15, 30 July 2024

Basic Info
Addressing Mode Opcode Length ROM Speed RAM Speed Cache Speed
Implied (type 1) 4D 1 byte 3 cycles 3 cycles 1 cycle
Flags Affected
B ALT1 ALT2 O/V S CY Z
0 0 0 . S . Z

SWAP is a Super FX instruction that swaps two bytes. The low byte of the source register is written to the high byte of the destination register, and the high byte of the source register is written to the low byte of the destination register. The source register itself is left unchanged.

The ALT0 state is restored.

The source and destination registers should be specified in advance using WITH, FROM, or TO. Otherwise, R0 serves as the default.

Syntax

SWAP

Example

Let:

Sreg : R3
Dreg : R13
R3 : 48d0h

After executing SWAP:

R13 = d048h

gsu swap.png

See Also

External Links