We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS
LOOP (Super FX): Difference between revisions
From SnesLab
(added official doc link) |
(made flags affected more prominent) |
||
(22 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{| class="wikitable" style="float:right;clear:right;width:50%" | |||
{| class="wikitable" style="float:right;clear:right;width: | |||
!colspan="8"|Basic Info | !colspan="8"|Basic Info | ||
|+ | |+ | ||
|'''Addressing Mode''' | |||
|'''Opcode''' | |'''Opcode''' | ||
|'''Length''' | |'''Length''' | ||
Line 10: | Line 9: | ||
|'''Cache Speed''' | |'''Cache Speed''' | ||
|+ | |+ | ||
|[[Implied]] (type 1) | |||
|3C | |3C | ||
|1 byte | |1 byte | ||
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 | |[[O/V]] | ||
|S | |[[Sign Flag|S]] | ||
|CY | |[[CY]] | ||
|Z | |[[Zero Flag|Z]] | ||
|+ | |+ | ||
|0 | |0 | ||
Line 32: | Line 32: | ||
|0 | |0 | ||
|. | |. | ||
| | |S | ||
|. | |. | ||
| | |Z | ||
|} | |} | ||
'''LOOP''' is a [[Super FX]] instruction that decrements R<sub>12</sub> by one. If the zero flag is set afterwards, R<sub>15</sub> is incremented. Otherwise, R<sub>13</sub> is stored to R<sub>15</sub>. | |||
The next instruction after LOOP is already loaded into the pipeline. | |||
The [[sign flag]] is set if R<sub>12</sub> is negative and cleared otherwise. | |||
The [[ALT0]] state is restored. | |||
==== Syntax ==== | |||
<pre> | |||
LOOP | |||
</pre> | |||
==== Example ==== | |||
In this program: | |||
00:8014 INC R<sub>7</sub> | |||
00:8015 INC R<sub>6</sub> | |||
00:8016 LOOP | |||
00:8017 NOP | |||
00:8018 ADD R<sub>4</sub> | |||
* If R<sub>13</sub> is 8014h and R<sub>12</sub> is not 0001h, the program jumps to 00:8014h after the NOP. | |||
* If R<sub>12</sub> is 0001h, the program does not jump and control falls through to the ADD. | |||
=== External Links === | === External Links === | ||
* Official Nintendo documentation on LOOP: https://archive.org/details/SNESDevManual/book2/page/n233 | * Official Nintendo documentation on LOOP: paragraph 9.54 on [https://archive.org/details/SNESDevManual/book2/page/n233 page 2-9-77 of Book II] | ||
[[Category:ASM]] | [[Category:ASM]] | ||
[[Category:Super FX]] | [[Category:Super FX]] | ||
[[Category:One-byte Instructions]] | |||
[[Category:Instructions with Delay Slots]] |
Latest revision as of 19:26, 30 July 2024
Basic Info | |||||||
---|---|---|---|---|---|---|---|
Addressing Mode | Opcode | Length | ROM Speed | RAM Speed | Cache Speed | ||
Implied (type 1) | 3C | 1 byte | 3 cycles | 3 cycles | 1 cycle |
Flags Affected | ||||||||
---|---|---|---|---|---|---|---|---|
B | ALT1 | ALT2 | O/V | S | CY | Z | ||
0 | 0 | 0 | . | S | . | Z |
LOOP is a Super FX instruction that decrements R12 by one. If the zero flag is set afterwards, R15 is incremented. Otherwise, R13 is stored to R15.
The next instruction after LOOP is already loaded into the pipeline.
The sign flag is set if R12 is negative and cleared otherwise. The ALT0 state is restored.
Syntax
LOOP
Example
In this program:
00:8014 INC R7 00:8015 INC R6 00:8016 LOOP 00:8017 NOP 00:8018 ADD R4
- If R13 is 8014h and R12 is not 0001h, the program jumps to 00:8014h after the NOP.
- If R12 is 0001h, the program does not jump and control falls through to the ADD.
External Links
- Official Nintendo documentation on LOOP: paragraph 9.54 on page 2-9-77 of Book II