We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS
MULT (Super FX): Difference between revisions
From SnesLab
(where product goes) |
(made flags affected more prominent) |
||
(21 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
!colspan="8"|Basic Info | !colspan="8"|Basic Info | ||
|+ | |+ | ||
|'''Addressing Mode''' | |||
|'''Opcode''' | |'''Opcode''' | ||
|'''Length''' | |'''Length''' | ||
Line 8: | Line 9: | ||
|'''Cache Speed''' | |'''Cache Speed''' | ||
|+ | |+ | ||
|[[Implied]] (type 1) | |||
|8n | |||
|1 byte | |||
|3 or 5 cycles | |||
|3 or 5 cycles | |||
|1 or 2 cycles | |||
|+ | |||
|[[Immediate]] | |||
|3E8n | |3E8n | ||
|2 bytes | |2 bytes | ||
Line 18: | Line 27: | ||
!colspan="9"|Flags Affected | !colspan="9"|Flags Affected | ||
|+ | |+ | ||
|B | |[[B Flag|B]] | ||
|[[ALT1]] | |[[ALT1]] | ||
|[[ALT2]] | |[[ALT2]] | ||
|[[O/V]] | |[[O/V]] | ||
|S | |[[Sign Flag|S]] | ||
|[[CY]] | |[[CY]] | ||
|Z | |[[Zero Flag|Z]] | ||
|+ | |+ | ||
|0 | |0 | ||
Line 30: | Line 39: | ||
|0 | |0 | ||
|. | |. | ||
| | |S | ||
|. | |. | ||
| | |Z | ||
|} | |} | ||
'''MULT''' is a [[Super FX]] instruction that performs a signed multiplication. The product is stored in the [[destination register]]. | '''MULT''' is a [[Super FX]] instruction that performs a signed multiplication. One of the factors is the low byte of the [[source register]]. The other factor may be any register from R<sub>0</sub> to R<sub>15</sub> or an immediate int from 0 to 15. The product is stored in the [[destination register]]. | ||
MULT utilizes the 8-bit multiplier only once, so it is fast.<sup>[2]</sup> | |||
The exact number of cycles depends on the state of the [[CFGR]] register. | |||
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. | |||
==== Syntax ==== | |||
<pre> | |||
MULT Rn | |||
MULT #n | |||
</pre> | |||
==== Example 1 ==== | |||
Let: | |||
S<sub>reg</sub> : R<sub>5</sub> | |||
D<sub>reg</sub> : R<sub>2</sub> | |||
R<sub>5</sub> = 52cfh | |||
R<sub>1</sub> = 63cfh | |||
After executing MULT R<sub>1</sub>: | |||
R<sub>2</sub> = 0961h | |||
==== Example 2 ==== | |||
Let: | |||
S<sub>reg</sub> : R<sub>3</sub> | |||
D<sub>reg</sub> : R<sub>4</sub> | |||
R<sub>3</sub> = 95c6h | |||
After executing MULT #9: | |||
R<sub>4</sub> = fdf6h | |||
=== See Also === | === See Also === | ||
* [[UMULT]] | * [[UMULT]] | ||
* [[FMULT]] | * [[FMULT]] | ||
* [[LMULT]] | |||
* [[DIV2]] | |||
* [[ALT2]] | |||
=== External Links === | === External Links === | ||
# Official Nintendo documentation on MULT: 9.66 on [https://archive.org/details/SNESDevManual/book2/page/n249 Page 2-9-93 of Book II] | |||
# 8.2 "Multiplication Instructions" on [https://archive.org/details/SNESDevManual/book2/page/n155 page 2-8-16 of Book II], lbid. | |||
[[Category:ASM]] | [[Category:ASM]] | ||
Line 48: | Line 92: | ||
[[Category:Arithmetic Operation Instructions]] | [[Category:Arithmetic Operation Instructions]] | ||
[[Category:Two-byte Instructions]] | [[Category:Two-byte Instructions]] | ||
[[Category:Expects Sreg/Dreg Prearranged]] |
Latest revision as of 19:22, 30 July 2024
Basic Info | |||||||
---|---|---|---|---|---|---|---|
Addressing Mode | Opcode | Length | ROM Speed | RAM Speed | Cache Speed | ||
Implied (type 1) | 8n | 1 byte | 3 or 5 cycles | 3 or 5 cycles | 1 or 2 cycles | ||
Immediate | 3E8n | 2 bytes | 6 or 8 cycles | 6 or 8 cycles | 2 or 3 cycles |
Flags Affected | ||||||||
---|---|---|---|---|---|---|---|---|
B | ALT1 | ALT2 | O/V | S | CY | Z | ||
0 | 0 | 0 | . | S | . | Z |
MULT is a Super FX instruction that performs a signed multiplication. One of the factors is the low byte of the source register. The other factor may be any register from R0 to R15 or an immediate int from 0 to 15. The product is stored in the destination register.
MULT utilizes the 8-bit multiplier only once, so it is fast.[2]
The exact number of cycles depends on the state of the CFGR register.
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
MULT Rn MULT #n
Example 1
Let:
Sreg : R5 Dreg : R2 R5 = 52cfh R1 = 63cfh
After executing MULT R1:
R2 = 0961h
Example 2
Let:
Sreg : R3 Dreg : R4 R3 = 95c6h
After executing MULT #9:
R4 = fdf6h
See Also
External Links
- Official Nintendo documentation on MULT: 9.66 on Page 2-9-93 of Book II
- 8.2 "Multiplication Instructions" on page 2-8-16 of Book II, lbid.