We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS
CMP (Super FX): Difference between revisions
From SnesLab
(moved tables up) |
(made flags affected more prominent) |
||
(23 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{| class="wikitable" style="float:right;clear:right;width: | {| class="wikitable" style="float:right;clear:right;width:50%" | ||
!colspan="8"|Basic Info | !colspan="8"|Basic Info | ||
|+ | |+ | ||
Line 9: | Line 9: | ||
|'''Cache Speed''' | |'''Cache Speed''' | ||
|+ | |+ | ||
| | |[[Implied]] (type 1) | ||
|3F6n | |3F6n | ||
|2 bytes | |2 bytes | ||
Line 18: | Line 18: | ||
{| class="wikitable" style="float:right;clear:right;width:30%" | {| class="wikitable" style="float:right;clear:right;width:30%" | ||
!colspan="9"|Flags | !colspan="9"|Flags Affected | ||
|+ | |+ | ||
|B | |[[B Flag|B]] | ||
|ALT1 | |[[ALT1]] | ||
|ALT2 | |[[ALT2]] | ||
|[[O/V]] | |||
|[[Sign Flag|S]] | |||
|[[CY]] | |||
|[[Zero Flag|Z]] | |||
|+ | |||
|0 | |||
|0 | |||
|0 | |||
|O/V | |O/V | ||
|S | |S | ||
|CY | |CY | ||
|Z | |Z | ||
|} | |} | ||
'''CMP''' is a [[Super FX]] instruction that compares the operand register with the [[source register]]. Internally, this is done via a subtraction, but the difference is not stored anywhere. | '''CMP''' (Compare) is a [[Super FX]] instruction that compares the operand register with the [[source register]]. Internally, this is done via a subtraction, but the difference is not stored anywhere. Thus, the purpose of CMP is to setup the flags. | ||
The operand serves as the subtrahend and can be any register from R<sub>0</sub> to R<sub>15</sup>. | |||
The [[ALT0]] state is restored. | |||
The source register should be specified in advance using [[WITH]] or [[FROM]]. Otherwise, R<sub>0</sub> serves as the default. | |||
==== Syntax ==== | |||
<pre> | |||
CMP Rn | |||
</pre> | |||
==== Example ==== | |||
Let: | |||
S<sub>reg</sub> : R<sub>1</sub> | |||
R<sub>1</sub> = 8000h | |||
R<sub>3</sub> = 2fffh | |||
After executing CMP R<sub>3</sub>, the overflow and carry flags are set but the sign and zero flags are clear. | |||
=== See Also === | |||
* [[CMP]] | |||
* [[SUB]] | |||
* [[SBC]] | |||
* [[ALT3]] | |||
=== External Links === | === External Links === | ||
* Official Nintendo documentation on CMP: [https://archive.org/details/SNESDevManual/book2/page/n197 | * Official Nintendo documentation on CMP: 9.29 on [https://archive.org/details/SNESDevManual/book2/page/n197 page 2-9-41 of Book II] | ||
[[Category:ASM]] | [[Category:ASM]] | ||
[[Category:Super FX]] | [[Category:Super FX]] | ||
[[Category:Two-byte Instructions]] | |||
[[Category:Expects Sreg/Dreg Prearranged]] |
Latest revision as of 18:42, 30 July 2024
Basic Info | |||||||
---|---|---|---|---|---|---|---|
Addressing Mode | Opcode | Length | ROM Speed | RAM Speed | Cache Speed | ||
Implied (type 1) | 3F6n | 2 bytes | 6 cycles | 6 cycles | 2 cycles |
Flags Affected | ||||||||
---|---|---|---|---|---|---|---|---|
B | ALT1 | ALT2 | O/V | S | CY | Z | ||
0 | 0 | 0 | O/V | S | CY | Z |
CMP (Compare) is a Super FX instruction that compares the operand register with the source register. Internally, this is done via a subtraction, but the difference is not stored anywhere. Thus, the purpose of CMP is to setup the flags.
The operand serves as the subtrahend and can be any register from R0 to R15.
The ALT0 state is restored.
The source register should be specified in advance using WITH or FROM. Otherwise, R0 serves as the default.
Syntax
CMP Rn
Example
Let:
Sreg : R1 R1 = 8000h R3 = 2fffh
After executing CMP R3, the overflow and carry flags are set but the sign and zero flags are clear.
See Also
External Links
- Official Nintendo documentation on CMP: 9.29 on page 2-9-41 of Book II