Fixed cycle delay: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
(Gotta have more data)
 
(47 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Delay code ==
Shortest possible CPU code that creates N cycles of delay, depending on constraints.
 
== Code ==
 
All code samples are written for CA65.
 
Assumptions:
* No page wrap occurs during any branch instruction. If a page wrap occurs, it adds +1 cycle for each loop, completely thwarting the accurate delay.
* No interrupt / NMI occurs during the delay code.


Shortest possible CPU code that creates N cycles of delay, depending on constraints.
It is permissible for DMA to steal cycles during the loops.
If you are expecting that to happen, you have to manually
adjust the delay cycle count (and it is in fact possible to do so)
in order to get the correct delay.


All branch instructions assume that no page wrap occurs.
=== Explanations on the requirements ===


Explanations on the requirements:
* @zp_temp means you have a zeropage address that you can write random data into.
* @rts12 means you know a memory address that contains byte $60 (<code>RTS</code>).
* @rts12 means you know a memory address that contains byte $60 (<code>RTS</code>).
* @rts14 means you know a memory address that contains a harmless 2-cycle instruction that fits your constraints (such as <code>CLC</code>, <code>LDA #0</code>, or <code>NOP</code>), followed by <code>RTS</code>.
cycle instruction that fits your constraints (such as <code>LDA $00</code>), followed by <code>RTS</code>.
* @rts15 means you know a memory address that contains a <code>JMP</code> that jumps to another location that contains <code>RTS</code>.
 
* Alternatively, @rts15 means you know a memory address that contains a harmless 3-cycle instruction that fits your constraints (such as <code>LDA $00</code>), followed by <code>RTS</code>.
=== Instructions, addressing modes, byte counts, cycle counts and notes ===
* @A, @X, @Y are local labels.
 
{| class="wikitable testtable"
! scope="col"| Addressing mode
! scope="col"| Instruction type
! scope="col"| Bytes
! scope="col"| Cycle count
! scope="col"| Example instruction
! scope="col"| Notes
|-
! scope="row"| Implied
! scope="row"| Inter-register
| 1 || 2 || <code>TAX</code> || <code>NOP</code> has no side effects. Flag-manipulations like <code>CLC</code>, and <code>SEC</code><code>CLV</code> are used when their effects are desired.
|-
! scope="row"| Implied
! scope="row"| Stack push
| 1 || 3 || <code>PHA</code> || <code>PHP</code> is only paired with <code>PLP</code>.
|-
! scope="row"| Implied
! scope="row"| Stack pop
| 1 || 4 || <code>PLA</code> ||
|-
! scope="row"| Implied
! scope="row"| Return
| 1 || 6 || <code>RTS</code> || Used indirectly when paired with <code>JSR</code>. Similarly for <code>RTI</code>.
|-
! scope="row"| Immediate
! scope="row"|
| 2 || 2 || <code>CMP #$C5</code> || Includes instructions like <code>LDA</code>, <code>LDX</code> and <code>LDY</code>. Other ALU instructions are used in more complex situations.
|-
! scope="row"| Relative
! scope="row"| Branch
| 2 || 2—4 || <code>BCC *+2</code> || Branch takes 3 cycles when taken, 2 otherwise. A page crossing adds +1 cycle when branch is taken, but because of difficulties setting that up, we don't use it.
|-
! scope="row"| Zeropage
! scope="row"| Read, write
| 2 || 3 || <code>LDA $A5</code>
|-
! scope="row"| Zeropage
! scope="row"| RMW
| 2 || 5 || <code>INC @zptemp</code> || Writing to zeropage is only permitted when @zptemp is available. Technically we could save @zptemp into register and restore at end, but it is bytewise inferior to other techniques.
|-
! scope="row"| Zeropage indexed
! scope="row"| Read, write
| 2 || 4 || <code>LDA $EA,X</code> || Inferior to 2 × <code>NOP</code>, but useful for hiding additional code to be executed in a loop.
|-
! scope="row"| Zeropage indexed
! scope="row"| RMW
| 2 || 6 || <code>INC @zptemp,X</code> || Only doable when X is known to be 0, or when entire zeropage can be clobbered.
|-
! scope="row"| Indexed indirect
! scope="row"| Read, write
| 2 || 6 || <code>STA (@ptrtemp,X)</code> || Only doable when X is known to be 0.
|-
! scope="row"| Indexed indirect
! scope="row"| RMW
| 2 || 8 || <code>SLO (@ptrtemp,X)</code> || The most cost-effective instruction. Only doable when X is known to be 0, lest we write to a random address. All instructions in this category are unofficial.
|-
! scope="row"| Indirect indexed
! scope="row"| Read
| 2 || 5—6 || <code>LDA (@ptrtemp),Y</code> || Never used by this code.
|-
! scope="row"| Indirect indexed
! scope="row"| Write
| 2 || 6        || <code>STA (@ptrtemp),Y</code> || Only doable when Y is known to be 0.
|-
! scope="row"| Indirect indexed
! scope="row"| RMW
| 2 || 8        || <code>SLO (@ptrtemp),Y</code> || All instructions in this category are unofficial.
|-
! scope="row"| Absolute
! scope="row"| Jump
| 3 || 3 || <code>JMP *+3</code> ||
|-
! scope="row"| Absolute
! scope="row"| Read, write
| 3 || 4 || <code>LDA $2808</code> || Inferior to 2 × <code>NOP</code>, but can be used carefully to hide additional code to be executed in a loop.
|-
! scope="row"| Absolute
! scope="row"| RMW
| 3 || 6 || <code>INC $4018</code> || Inferior to 3 × <code>NOP</code>.
|-
! scope="row"| Absolute indexed
! scope="row"| Read
| 3 || 4—5 || <code>LDA $0200,X</code> || Inferior to shorter alternatives.
|-
! scope="row"| Absolute indexed
! scope="row"| Write
| 3 || 5 || <code>STA $0200,X</code> || Inferior to shorter alternatives.
|-
! scope="row"| Absolute indexed
! scope="row"| RMW
| 3 || 7 || <code>INC $4018,X</code> || Only doable when writing into the given address is harmless considering the possible values of X.
|-
! scope="row"| Absolute indirect
! scope="row"| Jump
| 3 || 5 || <code>JMP (@ptrtemp)</code> || Inferior to shorter alternatives.
|}
 
{{#css:
  .testtable td{padding:2px} .testtable td pre{padding:2px;margin:2px}
}}
 


=== 2 cycles ===
=== 2 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|1 bytes
!colspan="2"|1 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|<pre>EA      NOP</pre>||No requirements
|-
|-
|}
|}
* All instructions cost at least 2 cycles. There is no way to do 1 cycle of delay (though <i>&minus;1 cycles</i> may sometimes appear in branch cost calculations).




=== 3 cycles ===
=== 3 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|1 bytes
!colspan="2"|2 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA</nowiki></pre> || style="padding:2px" | Clobbers S
|<pre>C5 C5    CMP $C5</pre>||Clobbers Z&N, and C
|-
|-
!colspan="2"|2 bytes
|<pre>24 24    BIT $24</pre>||Clobbers Z&N, and V
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDA $00</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|<pre>A5 A5    LDA $A5</pre>||Clobbers A, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>BIT $00</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V
|<pre>A6 A6    LDX $A6</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp</nowiki></pre> || style="padding:2px" | Requires @zptemp
|<pre>A4 A4    LDY $A4</pre>||Clobbers Y, and Z&N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
|-
!colspan="2"|3 bytes
!colspan="2"|3 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JMP *+3</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|<pre>4C xx xx JMP *+3</pre>||No requirements
|-
|-
|}
|}
* Not relocatable means that the target address is hardcoded into the code. In ROM hacking, it sometimes makes sense to move code blobs around, and a hardcoded address makes it difficult to relocate the code. This restriction does not apply to branches, which use relative addressing. It is also assumed to not apply to <code>JSR</code> instructions, as chances are the JSR target is outside the code being relocated.




=== 4 cycles ===
=== 4 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|1 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
!colspan="2"|2 bytes
!colspan="2"|2 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 2</pre>||No requirements
NOP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
* zp-indexed modes such as <code>LDA $00,X</code> also do 4 cycles, but having side effects, these two-byte instructions are inferior to a simple 2 × <code>NOP</code>.
* There is also an unofficial opcode <code>NOP $00,X</code> (34 00), but there is no reason to use this instruction when the official equivalent has the same performance.




=== 5 cycles ===
=== 5 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|2 bytes
!colspan="2"|3 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>18      CLC
PHA</nowiki></pre> || style="padding:2px" | Clobbers S
90 00    BCC *+2</pre>||Clobbers C
|-
|-
!colspan="2"|3 bytes
|<pre>B8      CLV
50 00    BVC *+2</pre>||Clobbers V
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
LDA $00</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
A5 A5    LDA $A5</pre>||Clobbers A, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
BIT $00</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V
A6 A6    LDX $A6</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
STA @zptemp</nowiki></pre> || style="padding:2px" | Requires @zptemp
A4 A4    LDY $A4</pre>||Clobbers Y, and Z&N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP $00</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
|-
!colspan="2"|4 bytes
!colspan="2"|4 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
JMP *+3</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
4C xx xx JMP *+3</pre>||No requirements
|-
|-
|}
|}
* abs-indexed modes such as <code>LDA $1234,X</code> cause 4 or 5 cycles of delay, depending whether a page wrap occurred. Because you need extra setup code to make sure that a wrap does occur, you do not see this mode in these samples, outside situations where circumstances permit.




=== 6 cycles ===
=== 6 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|2 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA</nowiki></pre> || style="padding:2px" | Clobbers S
|-
!colspan="2"|3 bytes
!colspan="2"|3 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 3</pre>||No requirements
NOP
NOP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
* zp-indexed RMW instructions such as <code>INC @zptemp,X</code> do 6 cycles. Unless we know the value of X, it might write into any address between $00-$FF. This option is only useful if the entire range of $00-$FF is free for clobbering with random data, or if X has a known value.
* ix instructions like <code>LDA ($00,X)</code> do 6 cycles, but the value of X decides where a pointer is read from, and said pointer can point anywhere. We only do that when the value of X is known.
* iy instructions like <code>LDA ($00),Y</code> also do 5-6 cycles, but in addition to the note above, we cannot predict whether a wrap occurs or not. So we don't use this mode.
* Absolute RMW instructions like <code>INC $4018</code> do 6 cycles, but weighing 3 bytes with side-effects it would be inferior to 3 × <code>NOP</code>.




=== 7 cycles ===
=== 7 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|2 bytes
!colspan="2"|2 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
28      PLP</pre>||No requirements
|-
|-
|}
|}
* <code>PHP-PLP</code> is very efficient for 7 cycles of delay, but it does modify stack contents. S register remains unchanged though.
* <code>PLA-PHA</code> does not overwrite any bytes in stack. It just writes back the same byte. But it does clobber A and Z+N. It is not interrupt-unsafe either: If an interrupt happens, the stack byte does get temporarily clobbered, but the value is still in A when the interrupt exits, and gets written back in stack.
* abs-indexed RMW instructions such as <code>INC abs,X</code> do 7 cycles. We only do this when either we know the value of X (for instance, <code>INC $4018,X</code> is safe when X is 0&mdash;7</code>, or when the entire 256-byte page can be safely overwritten with random data.




=== 8 cycles ===
=== 8 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|2 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
!colspan="2"|3 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TSX
PLA
TXS</nowiki></pre> || style="padding:2px" | Clobbers A, X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHA</nowiki></pre> || style="padding:2px" | Clobbers S
|-
!colspan="2"|4 bytes
!colspan="2"|4 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 4</pre>||No requirements
NOP
NOP
NOP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
* Unofficial ix and iy RMW instructions such as <code>SLO ($00,X)</code> or <code>SLO ($00),Y</code> would do 8 cycles for 2 bytes of code. We only do that if we know X or Y to be zero, and we have a known pointer to safely rewritable data.




=== 9 cycles ===
=== 9 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|3 bytes
!colspan="2"|3 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
PHP
08      PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
28      PLP</pre>||No requirements
|-
|-
|}
|}
* Jumping into the middle of another instruction and thereby reusing code is a very efficient way of reducing code size. Note that all code samples using branches on this page require that no page wrap occurs.




=== 10 cycles ===
=== 10 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|3 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
!colspan="2"|4 bytes
!colspan="2"|4 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
BIT $00
C5 C5    CMP $C5
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
28      PLP</pre>||No requirements
|-
|-
|}
|}
* The <code>ROL-ROR</code> sequence preserves the original value of the memory address. Carry is also preserved.




=== 11 cycles ===
=== 11 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|3 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
!colspan="2"|4 bytes
!colspan="2"|4 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 2
NOP
08      PHP
PHP
28      PLP</pre>||No requirements
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 188: Line 266:


=== 12 cycles ===
=== 12 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|3 bytes
!colspan="2"|3 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
|<pre>20 xx xx JSR @rts12</pre>||Requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
|-
!colspan="2"|4 bytes
!colspan="2"|4 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>ROL $00,X
|<pre>36 36    ROL $36,X
ROR $00,X</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
76 36    ROR $36,X</pre>||Clobbers Z&N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
|-
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>08      PHP
PHP
18      CLC
BIT $00
90 00   BCC *+2
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
28      PLP</pre>||No requirements
|-
|-
|}
|}
* <code>JSR-RTS</code> causes 12 cycles of delay. But it does write a function return address in the stack, which may be unwanted in some applications. S is not modified.
* Again, <code>ROL-ROR</code> does not have side effects (as long as an interrupt does not happen in the middle), except for Z+N.




=== 13 cycles ===
=== 13 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|4 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 3
NOP
08      PHP
NOP
28      PLP</pre>||No requirements
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 238: Line 300:


=== 14 cycles ===
=== 14 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|3 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
!colspan="2"|4 bytes
!colspan="2"|4 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP       \ × 2
PLP
28      PLP       /</pre>||No requirements
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 254: Line 310:


=== 15 cycles ===
=== 15 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|3 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
!colspan="2"|4 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDA $00
|<pre>08      PHP
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N; and requires @rts12
BA      TSX
|-
28      PLP
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
9A      TXS
TSX
28      PLP</pre>||Clobbers X
PLA
TXS
PLA</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TSX
PLA
TXS
PLP</nowiki></pre> || style="padding:2px" | Clobbers A, and X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>BIT $00
|<pre>C5 C5    CMP $C5
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts12
20 xx xx JSR @rts12</pre>||Clobbers Z&N, and C; and requires @rts12
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp
|<pre>24 24    BIT $24
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts12
20 xx xx JSR @rts12</pre>||Clobbers Z&N, and V; and requires @rts12
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>A5 A5    LDA $A5
PHA
20 xx xx JSR @rts12</pre>||Clobbers A, and Z&N; and requires @rts12
PHA
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00
|<pre>A4 A4    LDY $A4
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12, and support for unofficial opcodes
20 xx xx JSR @rts12</pre>||Clobbers Y, and Z&N; and requires @rts12
|-
|-
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>08      PHP
NOP
28      PLP
NOP
EA  ... NOP     × 4</pre>||No requirements
NOP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 314: Line 341:


=== 16 cycles ===
=== 16 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|4 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
PHP
08      PHP       \ × 2
PLP
28      PLP       /</pre>||No requirements
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 337: Line 352:


=== 17 cycles ===
=== 17 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|4 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDA $00
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>BIT $00
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14, and support for unofficial opcodes
|-
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PLP
48      PHA
PHP
A5 A5    LDA $A5
BIT $00
68      PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
28      PLP</pre>||No requirements
|-
|-
|}
|}
Line 378: Line 365:


=== 18 cycles ===
=== 18 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|4 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts14
|-
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDA $00
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>BIT $00
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15, and support for unofficial opcodes
|-
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 2
NOP
08      PHP       \ × 2
PHP
28      PLP       /</pre>||No requirements
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 428: Line 376:


=== 19 cycles ===
=== 19 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|4 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PLP
28      PLP
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
20 xx xx JSR @rts12</pre>||Requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
|-
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
ROL $00,X
36 36    ROL $36,X
ROR $00,X
76 36    ROR $36,X
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
28      PLP</pre>||No requirements
|-
|-
|}
|}
Line 465: Line 394:


=== 20 cycles ===
=== 20 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>A9 2A    LDA #$2A ;hides 'ROL A'
PHA
38      SEC
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
10 FC    BPL *-2</pre>||Clobbers A, Z&N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
!colspan="2"|6 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
LDA $00
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TSX
PLA
PLA
PLA
PLA
TXS</nowiki></pre> || style="padding:2px" | Clobbers A, X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
BIT $00
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
NOP
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
STA @zptemp
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP $00
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15, and support for unofficial opcodes
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 3
NOP
08      PHP       \ × 2
NOP
28      PLP       /</pre>||No requirements
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 533: Line 411:


=== 21 cycles ===
=== 21 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
|<pre>18      CLC
@Y:
A9 2A    LDA #$2A ;hides 'ROL A'
DEY
90 FD    BCC *-1</pre>||Clobbers A, Z&N, and C
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A2 04    LDX #4
PLP
CA      DEX
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>A0 04    LDY #4
PHA
88      DEY
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
|-
|-
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP       \ × 3
PLP
28      PLP       /</pre>||No requirements
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 567: Line 435:


=== 22 cycles ===
=== 22 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts14
|-
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
|<pre>18      CLC
@Y:
A9 2A    LDA #$2A ;hides 'ROL A'
NOP
38      SEC
DEY
10 FC    BPL *-2</pre>||Clobbers A, Z&N, and C
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>A2 02    LDX #2
PHP
EA      NOP
PLP
CA      DEX
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
10 FC    BPL *-2</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>A0 03    LDY #3
PLA
EA      NOP
PLA
88      DEY
PLA
D0 FC    BNE *-2</pre>||Clobbers Y, and Z&N
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHA
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
BIT $00
BA      TSX
PLP
08      PHP
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
28  ... PLP      × 2
|-
9A      TXS
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
28      PLP</pre>||Clobbers X
PHA
TSX
PLA
TXS
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
NOP
NOP
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>08      PHP
PHA
C5 C5    CMP $C5
PHA
28      PLP
PHP
20 xx xx JSR @rts12</pre>||Requires @rts12
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>08      PHP       \ × 2
NOP
28      PLP       /
NOP
EA  ... NOP      × 4</pre>||No requirements
NOP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 661: Line 477:


=== 23 cycles ===
=== 23 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TSX
|<pre>18  ... CLC      × 2
PLA
A9 2A    LDA #$2A ;hides 'ROL A'
TXS
90 FD    BCC *-1</pre>||Clobbers A, Z&N, and C
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, X, and Z&amp;N; and requires @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
PHP
A2 04    LDX #4
PLP
CA      DEX
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
PHA
A0 04    LDY #4
PHA
88      DEY
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
PHP
08      PHP       \ × 3
PLP
28      PLP       /</pre>||No requirements
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 706: Line 504:


=== 24 cycles ===
=== 24 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|6 bytes
!colspan="2"|4 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts12
|<pre>A9 0A    LDA #$0A ;hides 'ASL A'
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
10 FD    BPL *-1</pre>||Clobbers A, Z&N, and C
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
!colspan="2"|6 bytes
PHP
PLP
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
|<pre>20 xx xx JSR @rts12× 2</pre>||Requires @rts12
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHP
PLP
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TSX
|<pre>A6 A6    LDX $A6
PLA
A2 04    LDX #4
PLA
CA      DEX
PLA
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
PLA
PLA
TXS</nowiki></pre> || style="padding:2px" | Clobbers A, X, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A4 A4    LDY $A4
BIT $00
A0 04    LDY #4
PLP
88      DEY
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
.byte $0C,$E6,@zptemp ;NOP abs; hides 'INC @zptemp'
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires @zptemp, and support for unofficial opcodes
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PLP
C5 C5    CMP $C5
PHP
28      PLP       \ × 2
PLP
08      PHP       /
PHP
28      PLP</pre>||No requirements
BIT $00
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 774: Line 538:


=== 25 cycles ===
=== 25 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|6 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHP
PLP
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
PHA
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
PHA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts14
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>98      TYA
BIT $00
A0 04    LDY #4
PLP
88      DEY
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
D0 FD    BNE *-1
A8      TAY</pre>||Clobbers A, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #2
|<pre>EA  ... NOP      × 2
@Y:
A2 04    LDX #4
PHP
CA      DEX
PLP
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #2
|<pre>EA  ... NOP      × 2
@X:
A0 04    LDY #4
PHP
88      DEY
PLP
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
PHP
PLP
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
PHP
PLP
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 2
NOP
08      PHP       \ × 3
PHP
28      PLP       /</pre>||No requirements
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 855: Line 567:


=== 26 cycles ===
=== 26 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #5
|<pre>18      CLC
@Y:
A9 0A    LDA #$0A ;hides 'ASL A'
DEY
10 FD    BPL *-1</pre>||Clobbers A, Z&N, and C
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #5
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
!colspan="2"|6 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts12
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts12, and @rts14
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>A2 04    LDX #4
PLA
CA      DEX
PLA
10 FD    BPL *-1</pre>||Clobbers X, and Z&N
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
|<pre>A0 05    LDY #5
PLA
88      DEY
PLA
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts14
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
JSR @rts12
20 xx xx JSR @rts12× 2</pre>||Requires @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
PHP
PLP
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>ROL $00,X
ROR $00,X
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PLA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHP
PLP
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PLP
48      PHA
PHP
36 36    ROL $36,X
ROL $00,X
76 36    ROR $36,X
ROR $00,X
68      PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
28      PLP</pre>||No requirements
|-
|-
|}
|}
Line 934: Line 600:


=== 27 cycles ===
=== 27 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts12
|<pre>A5 A5    LDA $A5
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts12, and @rts15
A9 0A    LDA #$0A ;hides 'ASL A'
|-
10 FD    BPL *-1</pre>||Clobbers A, Z&N, and C
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
PLA
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>ROL $00,X
|<pre>48      PHA
ROR $00,X
A9 2A    LDA #$2A ;hides 'ROL A'
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N; and requires @rts15
38      SEC
10 FC    BPL *-2
68      PLA</pre>||Clobbers Z&N, and C
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>08      PHP
JSR @rts12
A9 2A    LDA #$2A ;hides 'ROL A'
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
38      SEC
10 FC    BPL *-2
28      PLP</pre>||Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>24 2C    BIT <$2C ;hides 'BIT $FDA2'
PHA
A2 FD    LDX #253
PHP
E8      INX
PLP
D0 FA    BNE *-4</pre>||Clobbers X, Z&N, and V
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>24 2C    BIT <$2C ;hides 'BIT $FDA0'
PLA
A0 FD    LDY #253
PLA
C8      INY
PLA
D0 FA    BNE *-4</pre>||Clobbers Y, Z&N, and V
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>A4 AC    LDY <$AC ;hides 'LDY $82A2'
PHA
A2 82    LDX #130
PHP
CA      DEX
PLP
30 FA    BMI *-4</pre>||Clobbers X, Y, and Z&N
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 3
PHP
A2 04    LDX #4
BIT $00
CA      DEX
PLP
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDA $00
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TSX
PLA
PLA
PLA
PLA
TXS
PLA</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TSX
PLA
PLA
PLA
PLA
TXS
PLP</nowiki></pre> || style="padding:2px" | Clobbers A, and X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>BIT $00
|<pre>EA  ... NOP      × 3
JSR @rts12
A0 04    LDY #4
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts12
88      DEY
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>24 24    BIT $24
NOP
20 xx xx JSR @rts12× 2</pre>||Clobbers Z&N, and V; and requires @rts12
NOP
PHP
PLP
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp
|<pre>20 xx xx JSR @rts12
JSR @rts12
08      PHP
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts12
BA      TSX
|-
28      PLP
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
9A      TXS
PHA
28      PLP</pre>||Clobbers X; and requires @rts12
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EAEA ;hides two 'NOP's
NOP
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 3
NOP
08      PHP       \ × 3
NOP
28      PLP       /</pre>||No requirements
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 1,058: Line 668:


=== 28 cycles ===
=== 28 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts14
|<pre>38  ... SEC      × 2
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1</pre>||Clobbers A, Z&N, and C
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
|<pre>EA      NOP
@X:
A2 04    LDX #4
PLA
CA      DEX
DEX
10 FD    BPL *-1</pre>||Clobbers X, and Z&N
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, S, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
|<pre>EA      NOP
@Y:
A0 05    LDY #5
PLA
88      DEY
DEY
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, S, and Z&amp;N
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>48      PHA
LDX #4
18      CLC
@X:
A9 2A    LDA #$2A ;hides 'ROL A'
DEX
90 FD    BCC *-1
BNE @X
68      PLA</pre>||Clobbers Z&N, and C
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #4
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>08      PHP
LDA #5
18      CLC
@A:
A9 2A    LDA #$2A ;hides 'ROL A'
SBC #1
90 FD    BCC *-1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
28      PLP</pre>||Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>08      PHP
PHA
A2 04    LDX #4
PHP
CA      DEX
PLP
D0 FD    BNE *-1
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
28      PLP</pre>||Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
|<pre>08      PHP
PLA
A0 04    LDY #4
PLA
88      DEY
PLA
D0 FD    BNE *-1
PLA
28      PLP</pre>||Clobbers Y
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP       \ × 4
PLP
28      PLP       /</pre>||No requirements
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 1,127: Line 720:


=== 29 cycles ===
=== 29 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
|<pre>18      CLC
@X:
A9 2A    LDA #$2A ;hides 'ROL A'
NOP
EA      NOP
DEX
90 FC    BCC *-2</pre>||Clobbers A, Z&N, and C
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
@Y:
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts14
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
PHP
PLP
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>A2 04    LDX #4
JSR @rts12
EA      NOP
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12, and @rts14
CA      DEX
D0 FC    BNE *-2</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>A0 04    LDY #4
PLA
EA      NOP
PLA
88      DEY
PLA
D0 FC    BNE *-2</pre>||Clobbers Y, and Z&N
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts14
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>48      PHA
LDY #3
18      CLC
@Y:
A9 2A    LDA #$2A ;hides 'ROL A'
NOP
38      SEC
DEY
10 FC    BPL *-2
BNE @Y
68      PLA</pre>||Clobbers Z&N, and C
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
LDX #3
18      CLC
@X:
A9 2A    LDA #$2A ;hides 'ROL A'
NOP
38      SEC
DEX
10 FC    BPL *-2
BNE @X
28      PLP</pre>||Clobbers A
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDA $00
|<pre>08      PHP
JSR @rts12
A2 02    LDX #2
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N; and requires @rts12, and @rts14
EA      NOP
CA      DEX
10 FC    BPL *-2
28      PLP</pre>||Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>BIT $00
|<pre>08      PHP
JSR @rts12
A0 03    LDY #3
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts12, and @rts14
EA      NOP
|-
88      DEY
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp
D0 FC    BNE *-2
JSR @rts12
28      PLP</pre>||Clobbers Y
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @zptemp, @rts12, and @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PLA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHA
PHP
PLP
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00
JSR @rts12
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts12, @rts14, and support for unofficial opcodes
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PLP
28      PLP
PHP
08      PHP
BIT $00
C5 C5    CMP $C5
PLP
28      PLP
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
20 xx xx JSR @rts12</pre>||Requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
NOP
NOP
PHP
PLP
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHA
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>08      PHP
NOP
C5 C5    CMP $C5
NOP
28      PLP
NOP
08      PHP
PHP
36 36    ROL $36,X
PLP
76 36    ROR $36,X
PHP
28      PLP</pre>||No requirements
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 1,282: Line 791:


=== 30 cycles ===
=== 30 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|6 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts15
|<pre>98      TYA
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
A0 05    LDY #5
88      DEY
D0 FD    BNE *-1
A8      TAY</pre>||Clobbers A, and Z&N
|-
|-
!colspan="2"|7 bytes
|<pre>EA  ... NOP      × 2
A2 04    LDX #4
CA      DEX
10 FD    BPL *-1</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 2
JSR @rts14
A0 05    LDY #5
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
88      DEY
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>48      PHA
PHA
18  ... CLC      × 2
JSR @rts12
A9 2A    LDA #$2A ;hides 'ROL A'
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
90 FD    BCC *-1
68      PLA</pre>||Clobbers Z&N, and C
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>08      PHP
PLA
18  ... CLC      × 2
PLA
A9 2A    LDA #$2A ;hides 'ROL A'
PLA
90 FD    BCC *-1
PLA
28      PLP</pre>||Clobbers A
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>EA      NOP
LDA #130
08      PHP
@A = * - 1
A2 04    LDX #4
; ^ Hides !NOP #imm
CA      DEX
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
D0 FD    BNE *-1
NOP
28      PLP</pre>||Clobbers X
SBC #1
|-
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|<pre>EA      NOP
08      PHP
A0 04    LDY #4
88      DEY
D0 FD    BNE *-1
28      PLP</pre>||Clobbers Y
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>08      PHP
PHP
48      PHA
PLP
18      CLC
PHP
A9 6A    LDA #$6A ;hides 'ROR A'
PLP
90 FD    BCC *-1
PHP
68      PLA
PLP
28      PLP</pre>||No requirements
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 1,335: Line 852:


=== 31 cycles ===
=== 31 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
|<pre>18      CLC
@Y:
A9 0A    LDA #$0A ;hides 'ASL A'
DEY
90 FD    BCC *-1</pre>||Clobbers A, Z&N, and C
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #6
|<pre>A2 05    LDX #5
@X:
CA      DEX
DEX
10 FD    BPL *-1</pre>||Clobbers X, and Z&N
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|7 bytes
|<pre>A0 06    LDY #6
88      DEY
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
!colspan="2"|6 bytes
JSR @rts14
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
|<pre>48      PHA
PLA
A9 0A    LDA #$0A ;hides 'ASL A'
PLA
10 FD    BPL *-1
PLA
68      PLA</pre>||Clobbers Z&N, and C
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>08      PHP
JSR @rts14
A9 0A    LDA #$0A ;hides 'ASL A'
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
10 FD    BPL *-1
28      PLP</pre>||Clobbers A
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PLP
28      PLP
JSR @rts12
20 xx xx JSR @rts12× 2</pre>||Requires @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHP
PLP
PHP
PLP
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #4
@A:
NOP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDA $00
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>BIT $00
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14, and support for unofficial opcodes
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
TSX
A6 A6    LDX $A6
PLA
A2 04    LDX #4
PLA
CA      DEX
PLA
D0 FD    BNE *-1
PLA
28      PLP</pre>||Clobbers X
PLA
TXS
PLP</nowiki></pre> || style="padding:2px" | Clobbers A, and X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JMP *+3
|<pre>08      PHP
JSR @rts14
A4 A4    LDY $A4
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
A0 04    LDY #4
|-
88      DEY
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
D0 FD    BNE *-1
PHP
28      PLP</pre>||Clobbers Y
PLP
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
.byte $0C,$E6,@zptemp ;NOP abs; hides 'INC @zptemp'
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires @zptemp, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
.byte $0C,$E6,@zptemp ;NOP abs; hides 'INC @zptemp'
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires @zptemp, and support for unofficial opcodes
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PLP
36 36    ROL $36,X \ × 2
PHP
76 36    ROR $36,X /
PLP
28      PLP</pre>||No requirements
PHP
PLP
PHP
BIT $00
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}
Line 1,472: Line 912:


=== 32 cycles ===
=== 32 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts14
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TSX
LDY #3
@Y:
PLA
DEY
BNE @Y
TXS</nowiki></pre> || style="padding:2px" | Clobbers A, X, Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #4
@Y:
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #2
@X:
PHP
PLP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #2
@Y:
PHP
PLP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHA
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
PHP
PLP
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 33 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
|<pre>A2 05    LDX #5 ;hides 'ORA zp'
@Y:
CA      DEX ;first loop only
PHA
CA      DEX
DEY
D0 FB    BNE *-3</pre>||Clobbers A, X, and Z&N
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
|<pre>A0 05    LDY #5 ;hides 'ORA zp'
@X:
88      DEY ;first loop only
PHA
88      DEY
DEX
D0 FB    BNE *-3</pre>||Clobbers A, Y, and Z&N
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A9 2A    LDA #$2A ;hides 'ROL A'
LDX #5
EA  ... NOP      × 3
@X:
10 FA    BPL *-4</pre>||Clobbers A, Z&N, and C
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #5
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #6
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDA $00
|<pre>EA      NOP
JSR @rts15
98      TYA
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N; and requires @rts15
A0 05    LDY #5
|-
88      DEY
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>BIT $00
D0 FD    BNE *-1
JSR @rts15
A8      TAY</pre>||Clobbers A, and Z&N
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
JSR @rts12
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts12, and @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
JSR @rts14
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>A6 A6    LDX $A6
PHA
A2 04    LDX #4
JSR @rts14
EA      NOP
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
CA      DEX
D0 FC    BNE *-2</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00
|<pre>A4 A4    LDY $A4
JSR @rts15
A0 04    LDY #4
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15, and support for unofficial opcodes
EA      NOP
88      DEY
D0 FC    BNE *-2</pre>||Clobbers Y, and Z&N
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>48      PHA
PHP
98      TYA
PLP
A0 04    LDY #4
JSR @rts12
88      DEY
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
D0 FD    BNE *-1
A8      TAY
68      PLA</pre>||Clobbers Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JMP *+3
|<pre>08      PHP
JSR @rts15
98      TYA
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
A0 04    LDY #4
88      DEY
D0 FD    BNE *-1
A8      TAY
28      PLP</pre>||Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts14
|<pre>EA  ... NOP      × 2
PHP
08      PHP
ROL $00,X
A2 04    LDX #4
ROR $00,X
CA      DEX
PLP</nowiki></pre> || style="padding:2px" | Requires @rts14
D0 FD    BNE *-1
28      PLP</pre>||Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA  ... NOP     × 2
PHA
08      PHP
PLA
A0 04    LDY #4
PLA
88      DEY
PLA
D0 FD    BNE *-1
PLA
28      PLP</pre>||Clobbers Y
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PLP
48      PHA
PHP
18  ... CLC      × 2
PLP
A9 6A    LDA #$6A ;hides 'ROR A'
PHP
90 FD    BCC *-1
ROL $00,X
68      PLA
ROR $00,X
28      PLP</pre>||No requirements
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 34 cycles ===
=== 33 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
PHA
PHA
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
PHA
PHA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
NOP
NOP
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
NOP
NOP
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
NOP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHP
PLP
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA ;hides 'NOP'
PHP
PLP
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
BIT $00
PLP
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TSX
PLA
PLA
PLA
PLA
TXS
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
PHP
PLP
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EAEA ;hides two 'NOP's
NOP
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EAEA ;hides two 'NOP's
NOP
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
NOP
PHP
PLP
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 35 cycles ===
{| class="wikitable"
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #2
@Y:
JSR @rts12
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #2
@X:
JSR @rts12
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #2
@X:
PLA
PLA
PLA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #2
@Y:
PLA
PLA
PLA
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #4
@A:
PHA
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #5
@A:
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #2
@X:
ROL $00,X
ROR $00,X
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #2
@Y:
ROL $00,X
ROR $00,X
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #5
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
BIT $00
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
STA @zptemp
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP $00
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15, and support for unofficial opcodes
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
PHP
PLP
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 36 cycles ===
{| class="wikitable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #7
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #7
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #4
@X:
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #4
@Y:
NOP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
JSR @rts14
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts14
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts12
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
NOP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHA
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
PHP
PLP
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #3
@A:
NOP
NOP
NOP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
NOP
NOP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #2
@Y:
PHP
PLP
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHA
PHP
PLP
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
|}
 
 
=== 37 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
|<pre>18  ... CLC      × 2
@Y:
A9 0A    LDA #$0A ;hides 'ASL A'
PLA
90 FD    BCC *-1</pre>||Clobbers A, Z&N, and C
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
@X:
PLA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, S, and Z&amp;N
|-
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
PHP
PLP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
PHP
PLP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #5
@Y:
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHP
PLP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
PHP
PLP
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
NOP
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>EA      NOP
SEC
A2 05    LDX #5
LDA #130
CA      DEX
@A = * - 1
10 FD    BPL *-1</pre>||Clobbers X, and Z&N
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
NOP
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|11 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>EA      NOP
PHP
A0 06    LDY #6
PLP
88      DEY
PHP
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
PLP
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
=== 38 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>48      PHA
LDY #6
18      CLC
@Y:
A9 0A    LDA #$0A ;hides 'ASL A'
DEY
10 FD    BPL *-1
BNE @Y
68      PLA</pre>||Clobbers Z&N, and C
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
LDX #6
18      CLC
@X:
A9 0A    LDA #$0A ;hides 'ASL A'
DEX
10 FD    BPL *-1
BNE @X
28      PLP</pre>||Clobbers A
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>08      PHP
LDA #7
A2 04    LDX #4
@A:
CA      DEX
SBC #1
10 FD    BPL *-1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
28      PLP</pre>||Clobbers X
|-
|-
!colspan="2"|8 bytes
|<pre>08      PHP
|-
A0 05    LDY #5
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
88      DEY
PLA
D0 FD    BNE *-1
JSR @rts15
28      PLP</pre>||Clobbers Y
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts12
|<pre>EA      NOP
JSR @rts12
08      PHP
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts12, and @rts14
28      PLP
|-
20 xx xx JSR @rts12× 2</pre>||Requires @rts12
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHP
PLP
JSR @rts14
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHA
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHP
PLP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>08      PHP       \ × 2
JSR @rts12
28      PLP       /
JSR @rts12
08      PHP
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
36 36    ROL $36,X
|-
76 36    ROR $36,X
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
28      PLP</pre>||No requirements
NOP
NOP
NOP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #4
@A:
NOP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #4
@A:
NOP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
BIT $00
PLP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHP
PLP
PHP
PLP
PHP
PLP
PHP
PLP
PHP
PLP</nowiki></pre> || style="padding:2px" | Clobbers S
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
.byte $0C,$E6,@zptemp ;NOP abs; hides 'INC @zptemp'
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires @zptemp, and support for unofficial opcodes
|-
|-
|}
|}




=== 39 cycles ===
=== 34 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|8 bytes
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #2
@Y:
JSR @rts14
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @rts14
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #2
|<pre>A9 0A    LDA #$0A ;hides 'ASL A'
@X:
18      CLC
JSR @rts14
10 FC    BPL *-2</pre>||Clobbers A, Z&N, and C
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @rts14
|-
|-
!colspan="2"|9 bytes
|<pre>A0 88    LDY #136 ;hides 'DEY'
88      DEY
30 FC    BMI *-2</pre>||Clobbers Y, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHP
PLP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #2
@Y:
PHP
PLP
PHP
PLP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #2
@X:
PHP
PLP
PHP
PLP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #3
@A:
PHP
PLP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts14
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TSX
LDY #3
@Y:
PLA
DEY
BNE @Y
TXS
PLP</nowiki></pre> || style="padding:2px" | Clobbers A, X, and Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
PHP
PLP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
JSR @rts12
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #4
@Y:
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TYA
PHA
LDY #4
@Y:
DEY
BNE @Y
PLA
TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp
JSR @rts12
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00
JSR @rts12
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12, and support for unofficial opcodes
|-
|}
=== 40 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
|<pre>A6 A6    LDX $A6
@Y:
A2 05    LDX #5
PLA
CA      DEX
PLA
10 FD    BPL *-1</pre>||Clobbers X, and Z&N
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
PLA
PLA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, S, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
|<pre>C5 C5    CMP $C5
@Y:
48      PHA
TSX
A9 0A    LDA #$0A ;hides 'ASL A'
PLA
10 FD    BPL *-1
TXS
68      PLA</pre>||Clobbers Z&N, and C
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, X, Y, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
|<pre>08      PHP
@Y:
A5 A5    LDA $A5
NOP
A9 0A    LDA #$0A ;hides 'ASL A'
PHA
10 FD    BPL *-1
PHA
28      PLP</pre>||Clobbers A
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
NOP
PHA
PHA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
SEC
48      PHA
LDA #6
A9 2A    LDA #$2A ;hides 'ROL A'
@A:
38      SEC
SBC #1
10 FC    BPL *-2
BNE @A
68      PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
28      PLP</pre>||No requirements
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
NOP
NOP
NOP
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
NOP
NOP
NOP
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #6
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts12
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts12, and @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHP
PLP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
BIT $00
PLP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>ROL $00,X
ROR $00,X
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHP
PLP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
JSR @rts12
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHP
BIT $00
PLP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
|-
|}
|}




=== 41 cycles ===
=== 35 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #8
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #8
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts12
JSR @rts14
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts12, @rts14, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
PHP
PLP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #3
@Y:
NOP
NOP
NOP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #3
@X:
NOP
NOP
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #2
@A:
JSR @rts14
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
PHP
PLP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EAEA ;hides two 'NOP's
NOP
PHP
PLP
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #2
@A:
PHP
PLP
PHP
PLP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
NOP
PHP
PLP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
JSR @rts12
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA ;hides 'NOP'
PHP
PLP
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA ;hides 'NOP'
PHP
PLP
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EAEA ;hides two 'NOP's
NOP
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
|}
 
 
=== 42 cycles ===
{| class="wikitable"
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts12
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts12, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #6
@Y:
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts14
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>ROL $00,X
ROR $00,X
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #2
@X:
JSR @rts12
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #2
@Y:
JSR @rts12
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHP
PLP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #5
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 43 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
|<pre>A9 2A    LDA #$2A ;hides 'ROL A'
@Y:
08      PHP
NOP
28      PLP
DEY
10 FB    BPL *-3</pre>||Clobbers A, Z&N, and C
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #6
@X:
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #7
@X:
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #7
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #8
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts14
JSR @rts14
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
PHP
PLP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
JSR @rts12
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts12, and @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA
PLA
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts14
|-
|-
!colspan="2"|11 bytes
|<pre>A2 F8    LDX #248 ;hides 'SED'
E8  ... INX      × 2
D0 FB    BNE *-3</pre>||Clobbers X, Z&N, and D
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A0 88    LDY #136 ;hides 'DEY'
PLP
88  ... DEY      × 2
JSR @rts12
30 FB    BMI *-3</pre>||Clobbers Y, and Z&N
JSR @rts12
JSR @rts12</nowiki></pre> || style="padding:2px" | Requires @rts12
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
NOP
PHP
PLP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA
PLA</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
PHA
PHP
PLP
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
PHP
PLP
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
PHP
PLP
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #3
@A:
NOP
NOP
NOP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #3
@A:
NOP
NOP
NOP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #2
@Y:
PHP
PLP
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
|}
=== 44 cycles ===
{| class="wikitable"
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #3
@X:
PHP
PLP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #3
@Y:
PHP
PLP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts14
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
PHP
PLP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
JSR @rts14
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
NOP
PHP
PLP
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #5
@Y:
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TYA
PHA
LDY #5
@Y:
DEY
BNE @Y
PLA
TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
NOP
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
|}
=== 45 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
|<pre>98      TYA
@Y:
A0 06    LDY #6
PHA
88      DEY
PHA
D0 FD    BNE *-1
DEY
A8      TAY</pre>||Clobbers A, and Z&N
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
|<pre>EA  ... NOP      × 2
@X:
A2 05    LDX #5
PHA
CA      DEX
PHA
10 FD    BPL *-1</pre>||Clobbers X, and Z&N
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
|<pre>48      PHA
@Y:
38  ... SEC      × 2
NOP
A9 0A    LDA #$0A ;hides 'ASL A'
NOP
10 FD    BPL *-1
NOP
68      PLA</pre>||Clobbers Z&N, and C
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
|<pre>08      PHP
@X:
38  ... SEC      × 2
NOP
A9 0A    LDA #$0A ;hides 'ASL A'
NOP
10 FD    BPL *-1
NOP
28      PLP</pre>||Clobbers A
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>EA      NOP
LDA #6
08      PHP
@A:
A2 04    LDX #4
NOP
CA      DEX
SBC #1
10 FD    BPL *-1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
28      PLP</pre>||Clobbers X
|-
|<pre>EA      NOP
08      PHP
A0 05    LDY #5
88      DEY
D0 FD    BNE *-1
28      PLP</pre>||Clobbers Y
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>JSR @rts15
|<pre>08      PHP
JSR @rts15
48      PHA
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
18      CLC
|-
A9 2A    LDA #$2A ;hides 'ROL A'
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
90 FD    BCC *-1
SEC
68      PLA
LDA #7
28      PLP</pre>||No requirements
@A:
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #7
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
JSR @rts14
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
JSR @rts12
JSR @rts12
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts12, and @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>BIT $00
JSR @rts14
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp
JSR @rts14
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00
JSR @rts14
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14, and support for unofficial opcodes
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #4
@A:
NOP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 46 cycles ===
=== 36 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #9
|<pre>A9 E9    LDA #$E9 ;hides 'SBC #$2A'
@Y:
2A      ROL A ;first loop only
DEY
B0 FC    BCS *-2</pre>||Clobbers A, Z&N, C, and V
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #9
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
JSR @rts14
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #2
@Y:
JSR @rts14
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #2
@X:
JSR @rts14
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
PLA
PLA
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
JSR @rts14
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
JSR @rts12
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires @rts12, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
PHA
PHP
PLP
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|11 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
|<pre>A2 07    LDX #7
PHP
CA      DEX
PLP
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
PHP
PLP
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A0 06    LDY #6
SEC
88      DEY
LDA #3
10 FD    BPL *-1</pre>||Clobbers Y, and Z&N
@A:
PHP
PLP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #2
@Y:
PHP
PLP
PHP
PLP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #2
@X:
PHP
PLP
PHP
PLP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #3
@A:
PHP
PLP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
JSR @rts14
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TYA
PHA
LDY #4
@Y:
DEY
BNE @Y
PLA
TAY
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
=== 47 cycles ===
{| class="wikitable"
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #7
@Y:
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #2
@Y:
PHA
JSR @rts15
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #2
@X:
PHA
JSR @rts15
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N; and requires @rts15
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
JSR @rts15
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
LDY #3
@Y:
TSX
PLA
TXS
DEY
BNE @Y
PLA</nowiki></pre> || style="padding:2px" | Clobbers X, Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #3
@Y:
TSX
PLA
TXS
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers A, X, and Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #2
@Y:
NOP
NOP
JSR @rts14
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #2
@X:
NOP
NOP
JSR @rts14
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #2
@Y:
PHA
PHA
JSR @rts12
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #2
@X:
PHA
PHA
JSR @rts12
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N; and requires @rts12
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #6
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
=== 48 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #8
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #8
@X:
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #9
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
JSR @rts15
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TXA
PHA
LDX #3
@X:
PHP
PLP
DEX
BNE @X
PLA
TAX</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>BIT $00
JSR @rts15
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and V; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
JSR @rts14
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>STA @zptemp
JSR @rts15
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @zptemp, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
JSR @rts14
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP $00
JSR @rts15
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15, and support for unofficial opcodes
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #2
@A:
JSR @rts14
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #2
@A:
JSR @rts14
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EAEA ;hides two 'NOP's
NOP
PHP
PLP
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EAEA ;hides two 'NOP's
NOP
PHP
PLP
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #2
@A:
PHP
PLP
PHP
PLP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #2
@A:
PHP
PLP
PHP
PLP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA ;hides 'NOP'
PHP
PLP
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
|}
=== 49 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
|<pre>38      SEC
@Y:
A9 0A    LDA #$0A ;hides 'ASL A'
PHA
38      SEC
DEY
10 FC    BPL *-2</pre>||Clobbers A, Z&N, and C
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #6
@X:
PHA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
@Y:
PHP
PLP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
@X:
PHP
PLP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
JSR @rts15
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA,X ;hides 'NOP'
JSR @rts14
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires @rts14, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $4848 ;hides two 'PHA's
JSR @rts12
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C; and requires @rts12, and support for unofficial opcodes
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
NOP
JSR @rts15
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #6
@Y:
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TYA
PHA
LDY #6
@Y:
DEY
BNE @Y
PLA
TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
JSR @rts14
JSR @rts14
JSR @rts14</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
|}
 
 
=== 50 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #7
@X:
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #7
@Y:
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #6
@Y:
NOP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #6
@X:
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #8
@A:
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #8
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PLP
JSR @rts14
JSR @rts14
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>NOP
PHA
JSR @rts15
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
PHP
PLP
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
!colspan="2"|14 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #3
@A:
NOP
NOP
NOP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 51 cycles ===
{| class="wikitable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #10
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #10
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>48      PHA
LDA #6
18      CLC
@A:
A9 2A    LDA #$2A ;hides 'ROL A'
PHA
EA      NOP
SBC #1
90 FC    BCC *-2
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C
68      PLA</pre>||Clobbers Z&N, and C
|-
|-
!colspan="2"|9 bytes
|<pre>08      PHP
18      CLC
A9 2A    LDA #$2A ;hides 'ROL A'
EA      NOP
90 FC    BCC *-2
28      PLP</pre>||Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>08      PHP
LDA #4
A2 04    LDX #4
@A:
EA      NOP
PHP
CA      DEX
PLP
D0 FC    BNE *-2
SBC #1
28      PLP</pre>||Clobbers X
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
|-
!colspan="2"|11 bytes
|<pre>08      PHP
|-
A0 04    LDY #4
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
EA      NOP
PLP
88      DEY
JSR @rts14
D0 FC    BNE *-2
JSR @rts15
28      PLP</pre>||Clobbers Y
JSR @rts15</nowiki></pre> || style="padding:2px" | Requires @rts14, and @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
PHA
JSR @rts15
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers S; and requires @rts15
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
NOP
PHP
PLP
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
NOP
PHP
PLP
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TYA
PHA
LDY #5
@Y:
DEY
BNE @Y
PLA
TAY
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 52 cycles ===
{| class="wikitable"
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
JSR @rts12
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
JSR @rts12
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #7
@A:
NOP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
PLA
PLA
PLA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
PLA
PLA
PLA
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, S, and Z&amp;N
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
|<pre>20 xx xx JSR @rts12× 3</pre>||Requires @rts12
PHA
LDY #8
@Y:
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
ROL $00,X
ROR $00,X
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
ROL $00,X
ROR $00,X
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
SEC
48      PHA
LDA #6
18      CLC
@A:
A9 2A    LDA #$2A ;hides 'ROL A'
NOP
38      SEC
SBC #1
10 FC    BPL *-2
BNE @A
68      PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
28      PLP</pre>||No requirements
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #4
@Y:
NOP
NOP
NOP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #4
@X:
NOP
NOP
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #6
@A:
NOP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #7
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 53 cycles ===
=== 37 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A5 A5    LDA $A5
LDX #9
A9 0A    LDA #$0A ;hides 'ASL A'
@X:
18      CLC
DEX
10 FC    BPL *-2</pre>||Clobbers A, Z&N, and C
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A2 04    LDX #4
LDY #9
EA  ... NOP      × 2
@Y:
CA      DEX
DEY
D0 FB    BNE *-3</pre>||Clobbers X, and Z&N
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>A0 04    LDY #4
LDA #10
EA  ... NOP     × 2
@A:
88      DEY
SBC #1
D0 FB    BNE *-3</pre>||Clobbers Y, and Z&N
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PLA
PLA
JSR @rts15
JSR @rts15
JSR @rts15</nowiki></pre> || style="padding:2px" | Clobbers A, S, and Z&amp;N; and requires @rts15
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
JSR @rts12
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires @rts12, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
JSR @rts12
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires @rts12, and support for unofficial opcodes
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #3
@A:
PHP
PLP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 54 cycles ===
{| class="wikitable"
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #6
@Y:
NOP
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #7
@Y:
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TYA
PHA
LDY #7
@Y:
DEY
BNE @Y
PLA
TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
LDY #3
@Y:
TSX
PLA
TXS
DEY
BNE @Y
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers X, and Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #2
@X:
NOP
NOP
JSR @rts14
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #2
@Y:
NOP
NOP
JSR @rts14
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y; and requires @rts14
|-
|}
 
 
=== 55 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
@Y:
PLA
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #6
@X:
PLA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, S, and Z&amp;N
|-
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
@Y:
NOP
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #6
@X:
NOP
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>CLC
|<pre>EA      NOP
LDA #250
98      TYA
@A = * - 1
A0 06    LDY #6
; ^ Hides !NOP
88      DEY
NOP
D0 FD    BNE *-1
ADC #1
A8      TAY</pre>||Clobbers A, and Z&N
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>48      PHA
SEC
98      TYA
LDA #9
A0 05    LDY #5
@A:
88      DEY
SBC #1
D0 FD    BNE *-1
BNE @A
A8      TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
68      PLA</pre>||Clobbers Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>08      PHP
SEC
98      TYA
LDA #9
A0 05    LDY #5
@A:
88      DEY
SBC #1
D0 FD    BNE *-1
BNE @A
A8      TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
28      PLP</pre>||Clobbers A
|-
|-
!colspan="2"|13 bytes
|<pre>EA  ... NOP      × 2
08      PHP
A2 04    LDX #4
CA      DEX
10 FD    BPL *-1
28      PLP</pre>||Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>EA  ... NOP     × 2
BIT $00
08      PHP
JSR @rts15
A0 05    LDY #5
JSR @rts15
88      DEY
JSR @rts15
D0 FD    BNE *-1
PLP</nowiki></pre> || style="padding:2px" | Requires @rts15
28      PLP</pre>||Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TXA
PHA
LDX #3
@X:
PHP
PLP
DEX
BNE @X
PLA
TAX
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
!colspan="2"|14 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #2
@A:
JSR @rts14
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EAEA ;hides two 'NOP's
NOP
PHP
PLP
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
!colspan="2"|15 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #2
@A:
PHP
PLP
PHP
PLP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 56 cycles ===
{| class="wikitable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #11
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #11
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #4
@X:
PHP
PLP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #4
@Y:
PHP
PLP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>08      PHP
LDA #130
48       PHA
@A = * - 1
18  ... CLC      × 2
; ^ Hides !NOP #imm
A9 2A    LDA #$2A ;hides 'ROL A'
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
90 FD    BCC *-1
JSR @rts15
68      PLA
SBC #1
28      PLP</pre>||No requirements
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires @rts15, and support for unofficial opcodes
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
.byte $0C,$E6,@zptemp ;NOP abs; hides 'INC @zptemp'
NOP
JSR @rts14
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires @zptemp, @rts14, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
PHA
JSR @rts12
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C; and requires @rts12, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $48,X ;hides 'PHA'
PHA
JSR @rts14
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C; and requires @rts14, and support for unofficial opcodes
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #4
@Y:
NOP
NOP
NOP
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA,X ;hides 'NOP'
JSR @rts14
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires @rts14, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA,X ;hides 'NOP'
JSR @rts14
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires @rts14, and support for unofficial opcodes
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TYA
PHA
LDY #6
@Y:
DEY
BNE @Y
PLA
TAY
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 57 cycles ===
=== 38 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #8
|<pre>38      SEC
@Y:
A9 69    LDA #$69 ;hides 'ADC #$EA'
NOP
EA      NOP ;first loop only
DEY
B0 FC    BCS *-2</pre>||Clobbers A, Z&N, C, and V
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #8
@X:
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|7 bytes
|<pre>EA      NOP
A2 07    LDX #7
CA      DEX
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>EA      NOP
LDA #136
A0 06    LDY #6
@A = * - 1
88      DEY
; ^ Hides DEY
10 FD    BPL *-1</pre>||Clobbers Y, and Z&N
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #7
@Y:
NOP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #7
@X:
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #9
@Y:
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #8
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
=== 58 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>48      PHA
LDX #10
18      CLC
@X:
A9 0A    LDA #$0A ;hides 'ASL A'
DEX
90 FD    BCC *-1
BNE @X
68      PLA</pre>||Clobbers Z&N, and C
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #10
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #11
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #4
@A:
PHP
PLP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #4
@A:
PHP
PLP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
|-
!colspan="2"|14 bytes
|<pre>08      PHP
18      CLC
A9 0A    LDA #$0A ;hides 'ASL A'
90 FD    BCC *-1
28      PLP</pre>||Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PHA
A2 05    LDX #5
SEC
CA      DEX
LDA #130
10 FD    BPL *-1
@A = * - 1
28      PLP</pre>||Clobbers X
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
NOP
PHP
PLP
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
|-
!colspan="2"|15 bytes
|<pre>08      PHP
A0 06    LDY #6
88      DEY
D0 FD    BNE *-1
28      PLP</pre>||Clobbers Y
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #3
@Y:
NOP
NOP
NOP
NOP
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
|}
=== 59 cycles ===
{| class="wikitable"
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TSX
|<pre>08      PHP
LDY #6
48      PHA
@Y:
A9 0A    LDA #$0A ;hides 'ASL A'
PLA
10 FD    BPL *-1
DEY
68      PLA
BNE @Y
28      PLP</pre>||No requirements
TXS</nowiki></pre> || style="padding:2px" | Clobbers A, X, Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #8
@A:
NOP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #7
@A:
NOP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #3
@Y:
JSR @rts12
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #3
@X:
JSR @rts12
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #7
@A:
NOP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #8
@Y:
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #3
@Y:
ROL $00,X
ROR $00,X
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #3
@X:
ROL $00,X
ROR $00,X
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #6
@A:
NOP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 60 cycles ===
=== 39 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|9 bytes
!colspan="2"|4 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A9 4A    LDA #$4A ;hides 'LSR A'
SEC
D0 FD    BNE *-1</pre>||Clobbers A, Z&N, and C
LDA #10
@A:
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
!colspan="2"|7 bytes
SEC
LDA #10
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
|-
!colspan="2"|14 bytes
|<pre>A6 A6    LDX $A6
A2 07    LDX #7
CA      DEX
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A4 A4    LDY $A4
PHA
A0 06    LDY #6
SEC
88      DEY
LDA #130
10 FD    BPL *-1</pre>||Clobbers Y, and Z&N
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
JSR @rts12
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires @rts12, and support for unofficial opcodes
|-
|}
 
 
=== 61 cycles ===
{| class="wikitable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #12
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #12
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>CLC
|<pre>98      TYA
LDA #250
A0 88    LDY #136 ;hides 'DEY'
@A = * - 1
88  ... DEY      × 2
; ^ Hides !NOP
30 FB    BMI *-3
PHA
A8      TAY</pre>||Clobbers A, and Z&N
ADC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>CLC
LDA #250
@A = * - 1
; ^ Hides !NOP
NOP $00
ADC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TXA
PHA
LDX #7
@X:
NOP
DEX
BNE @X
PLA
TAX</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
!colspan="2"|12 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>08      PHP
TYA
A2 05    LDX #5 ;hides 'ORA zp'
PHA
CA      DEX ;first loop only
LDY #6
CA      DEX
@Y:
D0 FB    BNE *-3
NOP
28      PLP</pre>||Clobbers A, and X
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
TYA
A0 05    LDY #5 ;hides 'ORA zp'
PHA
88      DEY ;first loop only
LDY #6
88      DEY
@Y:
D0 FB    BNE *-3
NOP
28      PLP</pre>||Clobbers A, and Y
DEY
BNE @Y
PLA
TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TYA
PHA
LDY #7
@Y:
DEY
BNE @Y
PLA
TAY
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
=== 62 cycles ===
{| class="wikitable"
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
|<pre>48      PHA
PHA
A9 2A    LDA #$2A ;hides 'ROL A'
LDY #10
EA  ... NOP      × 3
@Y:
10 FA    BPL *-4
DEY
68      PLA</pre>||Clobbers Z&N, and C
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
LDX #6
A9 2A    LDA #$2A ;hides 'ROL A'
@X:
EA  ... NOP     × 3
NOP
10 FA    BPL *-4
NOP
28      PLP</pre>||Clobbers A
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #6
@Y:
NOP
NOP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>EA      NOP
CLC
48      PHA
LDA #250
98      TYA
@A = * - 1
A0 05    LDY #5
; ^ Hides !NOP
88      DEY
NOP
D0 FD    BNE *-1
ADC #1
A8      TAY
BNE @A
68      PLA</pre>||Clobbers Z&N
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
CLC
LDA #250
@A = * - 1
; ^ Hides !NOP
NOP
ADC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #9
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 63 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
LDY #11
A6 A6    LDX $A6
@Y:
A2 04    LDX #4
DEY
EA      NOP
BNE @Y
CA      DEX
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
D0 FC    BNE *-2
28      PLP</pre>||Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
LDX #11
A4 A4    LDY $A4
@X:
A0 04    LDY #4
DEX
EA      NOP
BNE @X
88      DEY
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
D0 FC    BNE *-2
|-
28      PLP</pre>||Clobbers Y
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #12
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #3
@Y:
JSR @rts12
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
JSR @rts15
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires @rts15, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
JSR @rts15
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires @rts15, and support for unofficial opcodes
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #3
@Y:
ROL $00,X
ROR $00,X
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
.byte $0C,$E6,@zptemp ;NOP abs; hides 'INC @zptemp'
NOP
JSR @rts14
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires @zptemp, @rts14, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
.byte $0C,$E6,@zptemp ;NOP abs; hides 'INC @zptemp'
NOP
JSR @rts14
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires @zptemp, @rts14, and support for unofficial opcodes
|-
!colspan="2"|14 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #4
@Y:
NOP
NOP
NOP
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TYA
PHA
LDY #4
@Y:
NOP
NOP
NOP
DEY
BNE @Y
PLA
TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA,X ;hides 'NOP'
JSR @rts14
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires @rts14, and support for unofficial opcodes
|-
|}
 
 
=== 64 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #9
@X:
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #9
@Y:
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #8
@X:
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #8
@Y:
NOP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
|-
!colspan="2"|11 bytes
!colspan="2"|11 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>08      PHP
TYA
48      PHA
PHA
98      TYA
LDY #9
A0 04    LDY #4
@Y:
88      DEY
DEY
D0 FD    BNE *-1
BNE @Y
A8      TAY
PLA
68      PLA
TAY
28      PLP</pre>||No requirements
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
|-
|}
|}




=== 65 cycles ===
=== 40 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #8
|<pre>A2 05    LDX #5 ;hides 'ORA zp'
@X:
EA      NOP
PHA
CA      DEX
DEX
D0 FB    BNE *-3</pre>||Clobbers A, X, and Z&N
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #8
|<pre>A0 05    LDY #5 ;hides 'ORA zp'
@Y:
EA      NOP
PHA
88      DEY
DEY
D0 FB    BNE *-3</pre>||Clobbers A, Y, and Z&N
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #8
|<pre>98      TYA
@X:
A0 06    LDY #6
LDA $00
88      DEY
DEX
10 FD    BPL *-1
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, and Z&amp;N
A8      TAY</pre>||Clobbers A, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #8
|<pre>EA  ... NOP      × 2
@Y:
A2 07    LDX #7
LDA $00
CA      DEX
DEY
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #8
|<pre>EA  ... NOP      × 2
@X:
A0 06    LDY #6
BIT $00
88      DEY
DEX
10 FD    BPL *-1</pre>||Clobbers Y, and Z&N
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, Z&amp;N, and V
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #8
!colspan="2"|8 bytes
@Y:
BIT $00
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, Z&amp;N, and V
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #8
@X:
STA @zptemp
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @zptemp
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #8
|<pre>48      PHA
@Y:
18  ... CLC      × 2
STA @zptemp
A9 0A    LDA #$0A ;hides 'ASL A'
DEY
90 FD    BCC *-1
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @zptemp
68      PLA</pre>||Clobbers Z&N, and C
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #8
|<pre>08      PHP
@X:
18  ... CLC      × 2
NOP $00
A9 0A    LDA #$0A ;hides 'ASL A'
DEX
90 FD    BCC *-1
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires support for unofficial opcodes
28      PLP</pre>||Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #8
|<pre>EA      NOP
@Y:
08      PHP
NOP $00
A2 05    LDX #5
DEY
CA      DEX
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires support for unofficial opcodes
10 FD    BPL *-1
28      PLP</pre>||Clobbers X
|-
|-
!colspan="2"|8 bytes
|<pre>EA      NOP
|-
08      PHP
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #8
A0 06    LDY #6
@X:
88      DEY
JMP *+3
D0 FD    BNE *-1
DEX
28      PLP</pre>||Clobbers Y
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #8
@Y:
JMP *+3
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
SEC
48      PHA
LDA #11
18      CLC
@A:
A9 0A    LDA #$0A ;hides 'ASL A'
SBC #1
10 FD    BPL *-1
BNE @A
68      PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
28      PLP</pre>||No requirements
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #11
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #4
@A:
PHP
PLP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 66 cycles ===
=== 41 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #13
|<pre>38      SEC
@X:
A9 4A    LDA #$4A ;hides 'LSR A'
DEX
D0 FD    BNE *-1</pre>||Clobbers A, Z&N, and C
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #13
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
|-
!colspan="2"|7 bytes
|<pre>A2 08    LDX #8
CA      DEX
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>A0 08    LDY #8
LDA #137
88      DEY
@A = * - 1
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
; ^ Hides !NOP #imm
NOP
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #9
@A:
NOP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #8
@A:
NOP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #8
@A:
NOP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #7
@A:
NOP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
=== 67 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
|<pre>48      PHA
@Y:
A9 0A    LDA #$0A ;hides 'ASL A'
PHA
18      CLC
PHA
10 FC    BPL *-2
DEY
68      PLA</pre>||Clobbers Z&N, and C
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #6
@X:
PHA
PHA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #6
@X:
NOP
NOP
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
|<pre>08      PHP
@Y:
A9 0A    LDA #$0A ;hides 'ASL A'
NOP
18      CLC
NOP
10 FC    BPL *-2
NOP
28      PLP</pre>||Clobbers A
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>08      PHP
LDA #8
A0 88    LDY #136 ;hides 'DEY'
@A:
88      DEY
PHA
30 FC    BMI *-2
SBC #1
28      PLP</pre>||Clobbers Y
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TXA
|<pre>08      PHP
PHA
A6 A6    LDX $A6
LDX #11
A2 05    LDX #5
@X:
CA      DEX
DEX
10 FD    BPL *-1
BNE @X
28      PLP</pre>||Clobbers X
PLA
TAX</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
|-
!colspan="2"|11 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
PHA
48      PHA
SEC
A5 A5    LDA $A5
LDA #10
A9 0A    LDA #$0A ;hides 'ASL A'
@A:
10 FD    BPL *-1
SBC #1
68      PLA
BNE @A
28      PLP</pre>||No requirements
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 68 cycles ===
=== 42 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|7 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A5 A5    LDA $A5
LDX #12
A9 4A    LDA #$4A ;hides 'LSR A'
@X:
D0 FD    BNE *-1</pre>||Clobbers A, Z&N, and C
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
!colspan="2"|7 bytes
LDY #12
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>EA      NOP
LDA #13
A2 05    LDX #5 ;hides 'ORA zp'
@A:
EA      NOP
SBC #1
CA      DEX
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
D0 FB    BNE *-3</pre>||Clobbers A, X, and Z&N
|-
|-
!colspan="2"|10 bytes
|<pre>EA      NOP
A0 05    LDY #5 ;hides 'ORA zp'
EA      NOP
88      DEY
D0 FB    BNE *-3</pre>||Clobbers A, Y, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #8
@Y:
NOP
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
CLC
LDA #250
@A = * - 1
; ^ Hides !NOP
NOP $00
ADC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
CLC
LDA #250
@A = * - 1
; ^ Hides !NOP
NOP $00
ADC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TXA
PHA
LDX #7
@X:
NOP
DEX
BNE @X
PLA
TAX
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TXA
PHA
LDX #7
@X:
NOP
DEX
BNE @X
PLA
TAX
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
!colspan="2"|14 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TYA
PHA
LDY #6
@Y:
NOP
DEY
BNE @Y
PLA
TAY
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
=== 69 cycles ===
{| class="wikitable"
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
|<pre>48      PHA
@Y:
A9 2A    LDA #$2A ;hides 'ROL A'
JSR @rts12
08      PHP
DEY
28      PLP
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @rts12
10 FB    BPL *-3
68      PLA</pre>||Clobbers Z&N, and C
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
|<pre>08      PHP
@X:
A9 2A    LDA #$2A ;hides 'ROL A'
JSR @rts12
08      PHP
DEX
28      PLP
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @rts12
10 FB    BPL *-3
28      PLP</pre>||Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TSX
|<pre>08      PHP
LDY #8
A2 F8    LDX #248 ;hides 'SED'
@Y:
E8  ... INX      × 2
PHA
D0 FB    BNE *-3
DEY
28      PLP</pre>||Clobbers X
BNE @Y
TXS</nowiki></pre> || style="padding:2px" | Clobbers X, Y, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
|<pre>08      PHP
@Y:
A0 88    LDY #136 ;hides 'DEY'
PLA
88  ... DEY     × 2
PLA
30 FB    BMI *-3
PLA
28      PLP</pre>||Clobbers Y
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
@X:
PLA
PLA
PLA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, S, and Z&amp;N
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
|<pre>48      PHA
@Y:
98      TYA
ROL $00,X
A0 06    LDY #6
ROR $00,X
88      DEY
DEY
D0 FD    BNE *-1
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
A8      TAY
|-
68      PLA</pre>||Clobbers Z&N
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
@X:
ROL $00,X
ROR $00,X
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #6
@A:
PHA
PHA
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>08      PHP
LDA #6
48      PHA
@A:
38  ... SEC      × 2
NOP
A9 0A    LDA #$0A ;hides 'ASL A'
NOP
10 FD    BPL *-1
NOP
68      PLA
SBC #1
28      PLP</pre>||No requirements
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #10
@Y:
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TYA
PHA
LDY #10
@Y:
DEY
BNE @Y
PLA
TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
CLC
LDA #250
@A = * - 1
; ^ Hides !NOP
NOP
ADC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
|-
|}
|}




=== 70 cycles ===
=== 43 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|9 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>38  ... SEC     × 2
SEC
A9 4A    LDA #$4A ;hides 'LSR A'
LDA #12
D0 FD    BNE *-1</pre>||Clobbers A, Z&N, and C
@A:
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>A2 05    LDX #5
SEC
EA      NOP
LDA #12
CA      DEX
@A:
10 FC    BPL *-2</pre>||Clobbers X, and Z&N
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
|<pre>A0 06    LDY #6
@Y:
EA      NOP
PHA
88      DEY
JSR @rts15
D0 FC    BNE *-2</pre>||Clobbers Y, and Z&N
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N; and requires @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
!colspan="2"|7 bytes
@X:
PHA
JSR @rts15
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N; and requires @rts15
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
BIT $00
JSR @rts15
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, Z&amp;N, and V; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
BIT $00
JSR @rts15
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, Z&amp;N, and V; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
NOP
NOP
JSR @rts14
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @rts14
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
|<pre>48      PHA
@X:
A9 E9    LDA #$E9 ;hides 'SBC #$2A'
NOP
2A      ROL A ;first loop only
NOP
B0 FC    BCS *-2
JSR @rts14
68      PLA</pre>||Clobbers Z&N, C, and V
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @rts14
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
|<pre>08      PHP
@X:
A9 E9    LDA #$E9 ;hides 'SBC #$2A'
STA @zptemp
2A      ROL A ;first loop only
JSR @rts15
B0 FC    BCS *-2
DEX
28      PLP</pre>||Clobbers A
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @zptemp, and @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
|<pre>08      PHP
@Y:
A2 07    LDX #7
STA @zptemp
CA      DEX
JSR @rts15
D0 FD    BNE *-1
DEY
28      PLP</pre>||Clobbers X
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @zptemp, and @rts15
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
|<pre>08      PHP
@Y:
A0 06    LDY #6
PHA
88      DEY
PHA
10 FD    BPL *-1
JSR @rts12
28      PLP</pre>||Clobbers Y
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
PHA
PHA
JSR @rts12
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
NOP $00
JSR @rts15
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @rts15, and support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
NOP $00
JSR @rts15
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @rts15, and support for unofficial opcodes
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
NOP
NOP
PHP
PLP
PHP
PLP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #3
@X:
NOP
NOP
PHP
PLP
PHP
PLP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
!colspan="2"|14 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #3
@Y:
JSR @rts12
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
NOP $2808 ;hides 'PHP' and 'PLP'; reads from $2000
JSR @rts15
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires @rts15, and support for unofficial opcodes
|-
!colspan="2"|15 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #3
@Y:
ROL $00,X
ROR $00,X
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #130
@A = * - 1
; ^ Hides !NOP #imm
.byte $0C,$E6,@zptemp ;NOP abs; hides 'INC @zptemp'
NOP
JSR @rts14
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires @zptemp, @rts14, and support for unofficial opcodes
|-
!colspan="2"|16 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TYA
PHA
LDY #4
@Y:
NOP
NOP
NOP
DEY
BNE @Y
PLA
TAY
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 71 cycles ===
{| class="wikitable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #14
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #14
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>48      PHA
LDY #9
38      SEC
@Y:
A9 0A    LDA #$0A ;hides 'ASL A'
NOP
38      SEC
DEY
10 FC    BPL *-2
BNE @Y
68      PLA</pre>||Clobbers Z&N, and C
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #9
@X:
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>08      PHP
LDA #4
48      PHA
@A:
18      CLC
JSR @rts12
A9 2A    LDA #$2A ;hides 'ROL A'
SBC #1
EA      NOP
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires @rts12
90 FC    BCC *-2
|-
68      PLA
!colspan="2"|11 bytes
28      PLP</pre>||No requirements
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 72 cycles ===
=== 44 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #12
@Y:
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #8
@Y:
BIT $00
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #8
@X:
BIT $00
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #11
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 73 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #9
|<pre>A9 0A    LDA #$0A ;hides 'ASL A'
@Y:
EA  ... NOP      × 2
PHA
10 FB    BPL *-3</pre>||Clobbers A, Z&N, and C
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #9
|<pre>A0 88    LDY #136 ;hides 'DEY'
@X:
EA      NOP
PHA
88      DEY
DEX
30 FB    BMI *-3</pre>||Clobbers Y, and Z&N
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A6 A6    LDX $A6
LDX #13
A2 08    LDX #8
@X:
CA      DEX
DEX
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #13
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #14
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>C5 C5    CMP $C5
SEC
48      PHA
LDA #137
A9 0A    LDA #$0A ;hides 'ASL A'
@A = * - 1
18      CLC
; ^ Hides !NOP #imm
10 FC    BPL *-2
NOP
68      PLA</pre>||Clobbers Z&N, and C
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|10 bytes
|<pre>08      PHP
A5 A5    LDA $A5
A9 0A    LDA #$0A ;hides 'ASL A'
18      CLC
10 FC    BPL *-2
28      PLP</pre>||Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
SEC
A2 04    LDX #4
LDA #9
EA  ... NOP     × 2
@A:
CA      DEX
NOP
D0 FB    BNE *-3
SBC #1
28      PLP</pre>||Clobbers X
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>08      PHP
SEC
A0 04    LDY #4
LDA #9
EA  ... NOP     × 2
@A:
88      DEY
NOP
D0 FB    BNE *-3
SBC #1
28      PLP</pre>||Clobbers Y
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #8
@A:
NOP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
=== 74 cycles ===
{| class="wikitable"
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>EA      NOP
LDY #6
48      PHA
@Y:
98      TYA
NOP
A0 06    LDY #6
NOP
88      DEY
NOP
D0 FD    BNE *-1
DEY
A8      TAY
BNE @Y
68      PLA</pre>||Clobbers Z&N
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #6
@X:
NOP
NOP
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
|-
!colspan="2"|11 bytes
!colspan="2"|11 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>08      PHP
TXA
48      PHA
PHA
98      TYA
LDX #11
A0 05    LDY #5
@X:
88      DEY
DEX
D0 FD    BNE *-1
BNE @X
A8      TAY
PLA
68      PLA
TAX
28      PLP</pre>||No requirements
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TXA
PHA
LDX #11
@X:
DEX
BNE @X
PLA
TAX
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
|-
|}
|}




=== 75 cycles ===
=== 45 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #9
@A:
PHA
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #13
@A:
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #13
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #8
@Y:
NOP
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
CLC
LDA #250
@A = * - 1
; ^ Hides !NOP
NOP $00
ADC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
!colspan="2"|14 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TXA
PHA
LDX #7
@X:
NOP
DEX
BNE @X
PLA
TAX
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 76 cycles ===
{| class="wikitable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #15
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #15
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #4
@X:
JSR @rts12
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #4
@Y:
JSR @rts12
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TSX
LDY #8
@Y:
PHA
DEY
BNE @Y
TXS
PLP</nowiki></pre> || style="padding:2px" | Clobbers X, and Y
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TXA
PHA
LDX #8
@X:
LDA $00
DEX
BNE @X
PLA
TAX</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #4
@Y:
ROL $00,X
ROR $00,X
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #4
@X:
ROL $00,X
ROR $00,X
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #6
@A:
NOP
NOP
NOP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #6
@A:
NOP
NOP
NOP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TYA
PHA
LDY #10
@Y:
DEY
BNE @Y
PLA
TAY
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 77 cycles ===
{| class="wikitable"
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TSX
LDY #9
@Y:
PHA
DEY
BNE @Y
TXS</nowiki></pre> || style="padding:2px" | Clobbers X, Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
@X:
JSR @rts14
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
@Y:
JSR @rts14
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @rts14
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TXA
PHA
LDX #13
@X:
DEX
BNE @X
PLA
TAX</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #4
@X:
PHP
PLP
PHP
PLP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #4
@Y:
PHP
PLP
PHP
PLP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #12
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 78 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #11
@X:
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #11
@Y:
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>98      TYA
LDX #14
A0 08    LDY #8
@X:
88      DEY
DEX
D0 FD    BNE *-1
BNE @X
A8      TAY</pre>||Clobbers A, and Z&N
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #14
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #15
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
|-
!colspan="2"|12 bytes
|<pre>EA  ... NOP      × 2
A2 08    LDX #8
CA      DEX
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>EA  ... NOP     × 2
SEC
A0 08    LDY #8
LDA #4
88      DEY
@A:
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
JSR @rts12
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TXA
PHA
LDX #6
@X:
NOP
NOP
NOP
DEX
BNE @X
PLA
TAX</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #4
@A:
JSR @rts12
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires @rts12
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #4
@A:
ROL $00,X
ROR $00,X
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
|}
 
 
=== 79 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
@Y:
PLA
PLA
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #6
@X:
PLA
PLA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, S, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
|<pre>48      PHA
@Y:
38      SEC
TSX
A9 69    LDA #$69 ;hides 'ADC #$EA'
PLA
EA      NOP ;first loop only
TXS
B0 FC    BCS *-2
DEY
68      PLA</pre>||Clobbers Z&N, C, and V
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, X, Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #6
@X:
NOP
PHA
PHA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
@Y:
NOP
PHA
PHA
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #6
@X:
NOP
NOP
NOP
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #6
@Y:
NOP
NOP
NOP
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>CLC
LDA #250
@A = * - 1
; ^ Hides !NOP
PHA
PHA
ADC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #4
@A:
JSR @rts14
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires @rts14
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>CLC
|<pre>08      PHP
LDA #250
38      SEC
@A = * - 1
A9 69    LDA #$69 ;hides 'ADC #$EA'
; ^ Hides !NOP
EA      NOP ;first loop only
NOP
B0 FC    BCS *-2
NOP
28      PLP</pre>||Clobbers A
NOP
ADC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|11 bytes
|<pre>EA      NOP
08      PHP
A2 07    LDX #7
CA      DEX
D0 FD    BNE *-1
28      PLP</pre>||Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>EA      NOP
TYA
08      PHP
PHA
A0 06    LDY #6
LDY #12
88      DEY
@Y:
10 FD    BPL *-1
DEY
28      PLP</pre>||Clobbers Y
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TYA
PHA
LDY #12
@Y:
DEY
BNE @Y
PLA
TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
|}
 
 
=== 80 cycles ===
{| class="wikitable"
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #11
@A:
NOP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
SEC
48      PHA
LDA #14
18      CLC
@A:
A9 0A    LDA #$0A ;hides 'ASL A'
SBC #1
90 FD    BCC *-1
BNE @A
68      PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
28      PLP</pre>||No requirements
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #14
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #9
@A:
NOP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 81 cycles ===
=== 46 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|5 bytes
!colspan="2"|5 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #16
|<pre>A2 08    LDX #8
@Y:
CA      DEX
DEY
10 FD    BPL *-1</pre>||Clobbers X, and Z&N
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #16
|<pre>A0 09    LDY #9
@X:
88      DEY
DEX
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #136
@A = * - 1
; ^ Hides DEY
PHA
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #136
@A = * - 1
; ^ Hides DEY
BIT $00
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, C, and V
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #136
@A = * - 1
; ^ Hides DEY
STA @zptemp
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires @zptemp
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #136
@A = * - 1
; ^ Hides DEY
NOP $00
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #136
@A = * - 1
; ^ Hides DEY
JMP *+3
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TXA
PHA
LDX #11
@X:
DEX
BNE @X
PLA
TAX
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
=== 82 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #9
|<pre>48      PHA
@Y:
A9 4A    LDA #$4A ;hides 'LSR A'
PLA
D0 FD    BNE *-1
DEY
68      PLA</pre>||Clobbers Z&N, and C
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #9
@X:
PLA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, S, and Z&amp;N
|-
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #9
@Y:
NOP
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #9
|<pre>08      PHP
@X:
A9 4A    LDA #$4A ;hides 'LSR A'
NOP
D0 FD    BNE *-1
NOP
28      PLP</pre>||Clobbers A
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
|<pre>08      PHP
PHA
A6 A6    LDX $A6
LDY #14
A2 07    LDX #7
@Y:
CA      DEX
DEY
D0 FD    BNE *-1
BNE @Y
28      PLP</pre>||Clobbers X
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
|-
!colspan="2"|11 bytes
|<pre>08      PHP
|-
A4 A4    LDY $A4
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
A0 06    LDY #6
PHA
88      DEY
SEC
10 FD    BPL *-1
LDA #13
28      PLP</pre>||Clobbers Y
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 83 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #15
@X:
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #15
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #16
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TXA
PHA
LDX #8
@X:
LDA $00
DEX
BNE @X
PLA
TAX
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TXA
PHA
LDX #8
@X:
LDA $00
DEX
BNE @X
PLA
TAX
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
!colspan="2"|14 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #6
@A:
NOP
NOP
NOP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 84 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA,X ;hides 'NOP'
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #9
@A:
NOP
NOP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>48      PHA
TSX
98      TYA
LDY #9
A0 88    LDY #136 ;hides 'DEY'
@Y:
88  ... DEY     × 2
PHA
30 FB    BMI *-3
DEY
A8      TAY
BNE @Y
68      PLA</pre>||Clobbers Z&N
TXS
PLP</nowiki></pre> || style="padding:2px" | Clobbers X, and Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #4
@X:
JSR @rts14
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #4
@Y:
JSR @rts14
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y; and requires @rts14
|-
|-
!colspan="2"|11 bytes
!colspan="2"|11 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>08      PHP
TXA
48      PHA
PHA
A9 2A    LDA #$2A ;hides 'ROL A'
LDX #13
EA  ... NOP      × 3
@X:
10 FA    BPL *-4
DEX
68      PLA
BNE @X
28      PLP</pre>||No requirements
PLA
TAX
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TXA
PHA
LDX #13
@X:
DEX
BNE @X
PLA
TAX
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #4
@Y:
PHP
PLP
PHP
PLP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #4
@X:
PHP
PLP
PHP
PLP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
|-
|}
|}




=== 85 cycles ===
=== 47 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|6 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #12
|<pre>98      TYA
@Y:
A0 06    LDY #6
NOP
EA      NOP
DEY
88      DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
D0 FC    BNE *-2
A8      TAY</pre>||Clobbers A, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #12
|<pre>EA  ... NOP      × 3
@X:
A2 08    LDX #8
NOP
CA      DEX
DEX
D0 FD    BNE *-1</pre>||Clobbers X, and Z&N
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|8 bytes
|<pre>08      PHP
A2 05    LDX #5 ;hides 'ORA zp'
EA      NOP
CA      DEX
D0 FB    BNE *-3
28      PLP</pre>||Clobbers A, and X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>EA  ... NOP      × 3
LDX #11
A0 08    LDY #8
@X:
88      DEY
NOP
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
LDY #11
A0 05    LDY #5 ;hides 'ORA zp'
@Y:
EA      NOP
NOP
88      DEY
DEY
D0 FB    BNE *-3
BNE @Y
28      PLP</pre>||Clobbers A, and Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>48      PHA
SEC
98      TYA
LDA #15
A0 06    LDY #6
@A:
88      DEY
SBC #1
10 FD    BPL *-1
BNE @A
A8      TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
68      PLA</pre>||Clobbers Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>08      PHP
SEC
98      TYA
LDA #15
A0 06    LDY #6
@A:
88      DEY
SBC #1
10 FD    BPL *-1
BNE @A
A8      TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
28      PLP</pre>||Clobbers A
|-
|-
!colspan="2"|14 bytes
|<pre>EA  ... NOP      × 2
08      PHP
A2 07    LDX #7
CA      DEX
D0 FD    BNE *-1
28      PLP</pre>||Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>EA  ... NOP     × 2
PHA
08      PHP
SEC
A0 06    LDY #6
LDA #4
88      DEY
@A:
10 FD    BPL *-1
JSR @rts12
28      PLP</pre>||Clobbers Y
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires @rts12
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TXA
PHA
LDX #6
@X:
NOP
NOP
NOP
DEX
BNE @X
PLA
TAX
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
!colspan="2"|15 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #4
@A:
ROL $00,X
ROR $00,X
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 86 cycles ===
{| class="wikitable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #17
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #17
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
LDY #6
48      PHA
@Y:
18  ... CLC     × 2
TSX
A9 0A    LDA #$0A ;hides 'ASL A'
PLA
90 FD    BCC *-1
TXS
68      PLA
DEY
28      PLP</pre>||No requirements
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers A, X, and Y
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #6
@Y:
NOP
NOP
NOP
NOP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #6
@X:
NOP
NOP
NOP
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #4
@A:
JSR @rts14
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #4
@A:
JSR @rts14
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
CLC
LDA #250
@A = * - 1
; ^ Hides !NOP
NOP
NOP
NOP
ADC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
CLC
LDA #250
@A = * - 1
; ^ Hides !NOP
NOP
NOP
NOP
ADC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TYA
PHA
LDY #12
@Y:
DEY
BNE @Y
PLA
TAY
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 87 cycles ===
=== 48 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #12
@A:
NOP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #15
@Y:
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #11
@A:
NOP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #11
@A:
NOP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #14
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 88 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #16
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #16
@X:
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #17
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
BIT $00
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
BIT $00
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, C, and V
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
STA @zptemp
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires @zptemp
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
NOP $00
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
JMP *+3
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|16 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TXA
PHA
LDX #3
@X:
LDA $00
JSR @rts15
DEX
BNE @X
PLA
TAX
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N; and requires @rts15
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TXA
PHA
LDX #3
@X:
NOP
NOP
JSR @rts14
DEX
BNE @X
PLA
TAX
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N; and requires @rts14
|-
!colspan="2"|17 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #3
@Y:
NOP
NOP
PHP
PLP
PHP
PLP
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
|}
 
 
=== 89 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #11
|<pre>EA      NOP
@X:
A2 08    LDX #8
PHA
CA      DEX
DEX
10 FD    BPL *-1</pre>||Clobbers X, and Z&N
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #11
|<pre>EA      NOP
@Y:
A0 09    LDY #9
PHA
88      DEY
DEY
D0 FD    BNE *-1</pre>||Clobbers Y, and Z&N
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
|-
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #11
|<pre>48      PHA
@X:
38      SEC
LDA $00
A9 4A    LDA #$4A ;hides 'LSR A'
DEX
D0 FD    BNE *-1
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, and Z&amp;N
68      PLA</pre>||Clobbers Z&N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #11
@Y:
LDA $00
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #11
@X:
BIT $00
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, Z&amp;N, and V
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #11
@Y:
BIT $00
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, Z&amp;N, and V
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #11
@Y:
STA @zptemp
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires @zptemp
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #11
|<pre>08      PHP
@X:
38      SEC
STA @zptemp
A9 4A    LDA #$4A ;hides 'LSR A'
DEX
D0 FD    BNE *-1
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires @zptemp
28      PLP</pre>||Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #11
@Y:
NOP $00
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #11
@X:
NOP $00
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N; and requires support for unofficial opcodes
|-
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #11
|<pre>08      PHP
@X:
A2 08    LDX #8
JMP *+3
CA      DEX
DEX
D0 FD    BNE *-1
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
28      PLP</pre>||Clobbers X
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #11
|<pre>08      PHP
@Y:
A0 08    LDY #8
JMP *+3
88      DEY
DEY
D0 FD    BNE *-1
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
28      PLP</pre>||Clobbers Y
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
LDY #9
48      PHA
@Y:
A9 0A    LDA #$0A ;hides 'ASL A'
NOP
18      CLC
NOP
10 FC    BPL *-2
DEY
68      PLA
BNE @Y
28      PLP</pre>||No requirements
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #9
@X:
NOP
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #136
@A = * - 1
; ^ Hides DEY
NOP
NOP
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TXA
PHA
LDX #11
@X:
NOP
DEX
BNE @X
PLA
TAX</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #14
@Y:
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TYA
PHA
LDY #14
@Y:
DEY
BNE @Y
PLA
TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
|-
|}
|}




=== 90 cycles ===
=== 49 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|9 bytes
!colspan="2"|4 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A0 88    LDY #136 ;hides 'DEY'
SEC
30 FD    BMI *-1</pre>||Clobbers Y, and Z&N
LDA #16
@A:
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
!colspan="2"|7 bytes
SEC
LDA #16
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
|-
!colspan="2"|11 bytes
|<pre>18      CLC
A9 2A    LDA #$2A ;hides 'ROL A'
08      PHP
28      PLP
90 FB    BCC *-3</pre>||Clobbers A, Z&N, and C
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
|<pre>A6 A6    LDX $A6
TSX
A2 08    LDX #8
LDY #6
CA      DEX
@Y:
10 FD    BPL *-1</pre>||Clobbers X, and Z&N
PLA
PLA
DEY
BNE @Y
TXS
PLA</nowiki></pre> || style="padding:2px" | Clobbers X, Y, and Z&amp;N
|-
!colspan="2"|15 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TXA
PHA
LDX #8
@X:
LDA $00
DEX
BNE @X
PLA
TAX
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 91 cycles ===
{| class="wikitable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #18
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #18
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP $48 ;hides 'PHA'
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>C5 C5    CMP $C5
LDA #11
48      PHA
@A:
A9 4A    LDA #$4A ;hides 'LSR A'
PHA
D0 FD    BNE *-1
SBC #1
68      PLA</pre>||Clobbers Z&N, and C
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C
|-
|-
!colspan="2"|9 bytes
|<pre>08      PHP
|-
A5 A5    LDA $A5
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
A9 4A    LDA #$4A ;hides 'LSR A'
LDA #11
D0 FD    BNE *-1
@A:
28      PLP</pre>||Clobbers A
BIT $00
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, C, and V
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #11
@A:
STA @zptemp
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires @zptemp
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA,X ;hides 'NOP'
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA,X ;hides 'NOP'
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
|-
!colspan="2"|10 bytes
!colspan="2"|10 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>08      PHP
LDA #11
48      PHA
@A:
A9 2A    LDA #$2A ;hides 'ROL A'
JMP *+3
08      PHP
SBC #1
28      PLP
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
10 FB    BPL *-3
|-
68      PLA
!colspan="2"|11 bytes
28      PLP</pre>||No requirements
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #9
@A:
NOP
NOP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #9
@A:
NOP
NOP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TXA
PHA
LDX #13
@X:
DEX
BNE @X
PLA
TAX
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 92 cycles ===
=== 50 cycles ===
{| class="wikitable"
{| class="wikitable testtable"
!colspan="2"|6 bytes
!colspan="2"|6 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #13
|<pre>A9 E9    LDA #$E9 ;hides 'SBC #$2A'
@X:
2A      ROL A ;first loop only
NOP
EA      NOP
DEX
B0 FB    BCS *-3</pre>||Clobbers A, Z&N, C, and V
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #13
@Y:
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #12
@X:
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #12
@Y:
NOP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #16
@Y:
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
|-
!colspan="2"|11 bytes
|<pre>A2 07    LDX #7
EA      NOP
CA      DEX
D0 FC    BNE *-2</pre>||Clobbers X, and Z&N
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>A0 06    LDY #6
PHA
EA      NOP
SEC
88      DEY
LDA #15
10 FC    BPL *-2</pre>||Clobbers Y, and Z&N
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
=== 93 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
!colspan="2"|7 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>98      TYA
LDY #17
A0 09    LDY #9
@Y:
88      DEY
DEY
D0 FD    BNE *-1
BNE @Y
A8      TAY</pre>||Clobbers A, and Z&N
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #17
@X:
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #18
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #9
@Y:
NOP
NOP
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
!colspan="2"|14 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #4
@A:
JSR @rts14
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires @rts14
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
CLC
LDA #250
@A = * - 1
; ^ Hides !NOP
NOP
NOP
NOP
ADC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
|}
=== 94 cycles ===
{| class="wikitable"
!colspan="2"|8 bytes
!colspan="2"|8 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
|<pre>48      PHA
LDA #13
38  ... SEC     × 2
@A:
A9 4A    LDA #$4A ;hides 'LSR A'
NOP
D0 FD    BNE *-1
SBC #1
68      PLA</pre>||Clobbers Z&N, and C
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #12
@A:
NOP
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #3
@Y:
LDX #5
@X:
DEX
BNE @X
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers X, Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #12
@A:
NOP
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #15
@Y:
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #11
@A:
NOP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 95 cycles ===
{| class="wikitable"
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #17
@A:
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #17
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
BIT $00
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 96 cycles ===
{| class="wikitable"
!colspan="2"|5 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #19
@Y:
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #19
@X:
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|9 bytes
|<pre>08      PHP
38  ... SEC      × 2
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
28      PLP</pre>||Clobbers A
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
LDY #11
A2 05    LDX #5
@Y:
EA      NOP
BIT $00
CA      DEX
DEY
10 FC    BPL *-2
BNE @Y
28      PLP</pre>||Clobbers X
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
|<pre>08      PHP
LDX #11
A0 06    LDY #6
@X:
EA      NOP
BIT $00
88      DEY
DEX
D0 FC    BNE *-2
BNE @X
28      PLP</pre>||Clobbers Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
!colspan="2"|10 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TYA
PHA
LDY #12
@Y:
NOP
DEY
BNE @Y
PLA
TAY</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
NOP
NOP
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #136
@A = * - 1
; ^ Hides DEY
NOP
NOP
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TXA
PHA
LDX #11
@X:
NOP
DEX
BNE @X
PLA
TAX
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
TYA
PHA
LDY #14
@Y:
DEY
BNE @Y
PLA
TAY
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 97 cycles ===
{| class="wikitable"
!colspan="2"|6 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #12
@Y:
PHA
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #12
@X:
PHA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, S, and Z&amp;N
|-
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #8
@Y:
PHP
PLP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #8
@X:
PHP
PLP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
|-
!colspan="2"|9 bytes
!colspan="2"|9 bytes
|-
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>TXA
|<pre>08      PHP
PHA
48      PHA
LDX #17
A9 E9    LDA #$E9 ;hides 'SBC #$2A'
@X:
2A      ROL A ;first loop only
DEX
B0 FC    BCS *-2
BNE @X
68      PLA
PLA
28      PLP</pre>||No requirements
TAX</nowiki></pre> || style="padding:2px" | Clobbers A, and Z&amp;N
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #16
@A:
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|}
 
 
=== 98 cycles ===
{| class="wikitable"
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #18
@X:
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #18
@Y:
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #19
@A:
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #11
@A:
BIT $00
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #11
@A:
BIT $00
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, C, and V
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #11
@A:
STA @zptemp
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires @zptemp
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA,X ;hides 'NOP'
SBC #1
BMI @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Requires support for unofficial opcodes
|-
!colspan="2"|12 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #11
@A:
JMP *+3
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
PHA
SEC
LDA #9
@A:
NOP
NOP
SBC #1
BNE @A
PLA
PLP</nowiki></pre> || style="padding:2px" | Clobbers nothing, requires nothing
|-
|-
|}
|}




=== 99 cycles ===
== Sanity checks ==
{| class="wikitable"
!colspan="2"|6 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #14
@Y:
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #14
@X:
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
!colspan="2"|8 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDX #13
@X:
NOP
DEX
BNE @X
PLP</nowiki></pre> || style="padding:2px" | Clobbers X
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
LDY #13
@Y:
NOP
DEY
BNE @Y
PLP</nowiki></pre> || style="padding:2px" | Clobbers Y
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #12
@A:
PHA
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, S, Z&amp;N, and C
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #8
@A:
PHP
PLP
SBC #1
BNE @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
SBC #1
BMI @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A; and requires support for unofficial opcodes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP $EA44 ;hides 'NOP zp'
SBC #1
BMI @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|11 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #16
@Y:
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
TYA
PHA
LDY #16
@Y:
DEY
BNE @Y
PLA
TAY
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
|}


It is possible to verify on compile time that no page wrap occurs,
by replacing all branches with these macros:
<pre>.macro branch_check opc, dest
    opc dest
    .assert >* = >(dest), warning, "branch_check: failed, crosses page"
.endmacro
.macro bccnw dest
        branch_check bcc, dest
.endmacro
.macro bcsnw dest
        branch_check bcs, dest
.endmacro
.macro beqnw dest
        branch_check beq, dest
.endmacro
.macro bnenw dest
        branch_check bne, dest
.endmacro
.macro bminw dest
        branch_check bmi, dest
.endmacro
.macro bplnw dest
        branch_check bpl, dest
.endmacro
.macro bvcnw dest
        branch_check bvc, dest
.endmacro
.macro bvsnw dest
        branch_check bvs, dest
.endmacro</pre>


=== 100 cycles ===
== See also ==
{| class="wikitable"
!colspan="2"|6 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #11
@Y:
PLA
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers A, Y, S, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #11
@X:
PLA
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers A, X, S, and Z&amp;N
|-
!colspan="2"|7 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDY #11
@Y:
NOP
NOP
DEY
BNE @Y</nowiki></pre> || style="padding:2px" | Clobbers Y, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>LDX #11
@X:
NOP
NOP
DEX
BNE @X</nowiki></pre> || style="padding:2px" | Clobbers X, and Z&amp;N
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>SEC
LDA #137
@A = * - 1
; ^ Hides !NOP #imm
NOP $EAEA ;hides two 'NOP's
SBC #1
BMI @A</nowiki></pre> || style="padding:2px" | Clobbers A, Z&amp;N, and C; and requires support for unofficial opcodes
|-
!colspan="2"|9 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHP
SEC
LDA #18
@A:
SBC #1
BNE @A
PLP</nowiki></pre> || style="padding:2px" | Clobbers A
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
SEC
LDA #18
@A:
SBC #1
BNE @A
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N, and C
|-
!colspan="2"|13 bytes
|-
| style="padding:2px" |<pre style="margin:2px;padding:3px"><nowiki>PHA
TYA
PHA
LDY #9
@Y:
NOP
NOP
DEY
BNE @Y
PLA
TAY
PLA</nowiki></pre> || style="padding:2px" | Clobbers Z&amp;N
|-
|}


== More ==
* [[Cycle counting]]
Bisqwit's 6502 delay_n macro set for ca65: http://bisqwit.iki.fi/src/6502-inline_delay.7z
* [[Delay code]] for functions that produce runtime-determined amount of delay
* Bisqwit’s “vending machine” for producing a ca65-compatible delay_n macro for arbitrary number of cycles, with more fine-grained configurable constraints: http://bisqwit.iki.fi/utils/nesdelay.php The samples on this page are excerpts from files generated by this online tool.

Latest revision as of 18:24, 12 November 2020

Shortest possible CPU code that creates N cycles of delay, depending on constraints.

Code

All code samples are written for CA65.

Assumptions:

  • No page wrap occurs during any branch instruction. If a page wrap occurs, it adds +1 cycle for each loop, completely thwarting the accurate delay.
  • No interrupt / NMI occurs during the delay code.

It is permissible for DMA to steal cycles during the loops. If you are expecting that to happen, you have to manually adjust the delay cycle count (and it is in fact possible to do so) in order to get the correct delay.

Explanations on the requirements

  • @rts12 means you know a memory address that contains byte $60 (RTS).

cycle instruction that fits your constraints (such as LDA $00), followed by RTS.

Instructions, addressing modes, byte counts, cycle counts and notes

Addressing mode Instruction type Bytes Cycle count Example instruction Notes
Implied Inter-register 1 2 TAX NOP has no side effects. Flag-manipulations like CLC, and SECCLV are used when their effects are desired.
Implied Stack push 1 3 PHA PHP is only paired with PLP.
Implied Stack pop 1 4 PLA
Implied Return 1 6 RTS Used indirectly when paired with JSR. Similarly for RTI.
Immediate 2 2 CMP #$C5 Includes instructions like LDA, LDX and LDY. Other ALU instructions are used in more complex situations.
Relative Branch 2 2—4 BCC *+2 Branch takes 3 cycles when taken, 2 otherwise. A page crossing adds +1 cycle when branch is taken, but because of difficulties setting that up, we don't use it.
Zeropage Read, write 2 3 LDA $A5
Zeropage RMW 2 5 INC @zptemp Writing to zeropage is only permitted when @zptemp is available. Technically we could save @zptemp into register and restore at end, but it is bytewise inferior to other techniques.
Zeropage indexed Read, write 2 4 LDA $EA,X Inferior to 2 × NOP, but useful for hiding additional code to be executed in a loop.
Zeropage indexed RMW 2 6 INC @zptemp,X Only doable when X is known to be 0, or when entire zeropage can be clobbered.
Indexed indirect Read, write 2 6 STA (@ptrtemp,X) Only doable when X is known to be 0.
Indexed indirect RMW 2 8 SLO (@ptrtemp,X) The most cost-effective instruction. Only doable when X is known to be 0, lest we write to a random address. All instructions in this category are unofficial.
Indirect indexed Read 2 5—6 LDA (@ptrtemp),Y Never used by this code.
Indirect indexed Write 2 6 STA (@ptrtemp),Y Only doable when Y is known to be 0.
Indirect indexed RMW 2 8 SLO (@ptrtemp),Y All instructions in this category are unofficial.
Absolute Jump 3 3 JMP *+3
Absolute Read, write 3 4 LDA $2808 Inferior to 2 × NOP, but can be used carefully to hide additional code to be executed in a loop.
Absolute RMW 3 6 INC $4018 Inferior to 3 × NOP.
Absolute indexed Read 3 4—5 LDA $0200,X Inferior to shorter alternatives.
Absolute indexed Write 3 5 STA $0200,X Inferior to shorter alternatives.
Absolute indexed RMW 3 7 INC $4018,X Only doable when writing into the given address is harmless considering the possible values of X.
Absolute indirect Jump 3 5 JMP (@ptrtemp) Inferior to shorter alternatives.

{{#css:

 .testtable td{padding:2px} .testtable td pre{padding:2px;margin:2px}

}}


2 cycles

1 bytes
EA       NOP
No requirements
  • All instructions cost at least 2 cycles. There is no way to do 1 cycle of delay (though −1 cycles may sometimes appear in branch cost calculations).


3 cycles

2 bytes
C5 C5    CMP $C5
Clobbers Z&N, and C
24 24    BIT $24
Clobbers Z&N, and V
A5 A5    LDA $A5
Clobbers A, and Z&N
A6 A6    LDX $A6
Clobbers X, and Z&N
A4 A4    LDY $A4
Clobbers Y, and Z&N
3 bytes
4C xx xx JMP *+3
No requirements
  • Not relocatable means that the target address is hardcoded into the code. In ROM hacking, it sometimes makes sense to move code blobs around, and a hardcoded address makes it difficult to relocate the code. This restriction does not apply to branches, which use relative addressing. It is also assumed to not apply to JSR instructions, as chances are the JSR target is outside the code being relocated.


4 cycles

2 bytes
EA   ... NOP      × 2
No requirements
  • zp-indexed modes such as LDA $00,X also do 4 cycles, but having side effects, these two-byte instructions are inferior to a simple 2 × NOP.
  • There is also an unofficial opcode NOP $00,X (34 00), but there is no reason to use this instruction when the official equivalent has the same performance.


5 cycles

3 bytes
18       CLC
90 00    BCC *+2
Clobbers C
B8       CLV
50 00    BVC *+2
Clobbers V
EA       NOP
A5 A5    LDA $A5
Clobbers A, and Z&N
EA       NOP
A6 A6    LDX $A6
Clobbers X, and Z&N
EA       NOP
A4 A4    LDY $A4
Clobbers Y, and Z&N
4 bytes
EA       NOP
4C xx xx JMP *+3
No requirements
  • abs-indexed modes such as LDA $1234,X cause 4 or 5 cycles of delay, depending whether a page wrap occurred. Because you need extra setup code to make sure that a wrap does occur, you do not see this mode in these samples, outside situations where circumstances permit.


6 cycles

3 bytes
EA   ... NOP      × 3
No requirements
  • zp-indexed RMW instructions such as INC @zptemp,X do 6 cycles. Unless we know the value of X, it might write into any address between $00-$FF. This option is only useful if the entire range of $00-$FF is free for clobbering with random data, or if X has a known value.
  • ix instructions like LDA ($00,X) do 6 cycles, but the value of X decides where a pointer is read from, and said pointer can point anywhere. We only do that when the value of X is known.
  • iy instructions like LDA ($00),Y also do 5-6 cycles, but in addition to the note above, we cannot predict whether a wrap occurs or not. So we don't use this mode.
  • Absolute RMW instructions like INC $4018 do 6 cycles, but weighing 3 bytes with side-effects it would be inferior to 3 × NOP.


7 cycles

2 bytes
08       PHP
28       PLP
No requirements
  • PHP-PLP is very efficient for 7 cycles of delay, but it does modify stack contents. S register remains unchanged though.
  • PLA-PHA does not overwrite any bytes in stack. It just writes back the same byte. But it does clobber A and Z+N. It is not interrupt-unsafe either: If an interrupt happens, the stack byte does get temporarily clobbered, but the value is still in A when the interrupt exits, and gets written back in stack.
  • abs-indexed RMW instructions such as INC abs,X do 7 cycles. We only do this when either we know the value of X (for instance, INC $4018,X is safe when X is 0—7, or when the entire 256-byte page can be safely overwritten with random data.


8 cycles

4 bytes
EA   ... NOP      × 4
No requirements
  • Unofficial ix and iy RMW instructions such as SLO ($00,X) or SLO ($00),Y would do 8 cycles for 2 bytes of code. We only do that if we know X or Y to be zero, and we have a known pointer to safely rewritable data.


9 cycles

3 bytes
EA       NOP
08       PHP
28       PLP
No requirements
  • Jumping into the middle of another instruction and thereby reusing code is a very efficient way of reducing code size. Note that all code samples using branches on this page require that no page wrap occurs.


10 cycles

4 bytes
08       PHP
C5 C5    CMP $C5
28       PLP
No requirements
  • The ROL-ROR sequence preserves the original value of the memory address. Carry is also preserved.


11 cycles

4 bytes
EA   ... NOP      × 2
08       PHP
28       PLP
No requirements


12 cycles

3 bytes
20 xx xx JSR @rts12
Requires @rts12
4 bytes
36 36    ROL $36,X
76 36    ROR $36,X
Clobbers Z&N
5 bytes
08       PHP
18       CLC
90 00    BCC *+2
28       PLP
No requirements
  • JSR-RTS causes 12 cycles of delay. But it does write a function return address in the stack, which may be unwanted in some applications. S is not modified.
  • Again, ROL-ROR does not have side effects (as long as an interrupt does not happen in the middle), except for Z+N.


13 cycles

5 bytes
EA   ... NOP      × 3
08       PHP
28       PLP
No requirements


14 cycles

4 bytes
08       PHP       \ × 2
28       PLP       /
No requirements


15 cycles

5 bytes
08       PHP
BA       TSX
28       PLP
9A       TXS
28       PLP
Clobbers X
C5 C5    CMP $C5
20 xx xx JSR @rts12
Clobbers Z&N, and C; and requires @rts12
24 24    BIT $24
20 xx xx JSR @rts12
Clobbers Z&N, and V; and requires @rts12
A5 A5    LDA $A5
20 xx xx JSR @rts12
Clobbers A, and Z&N; and requires @rts12
A4 A4    LDY $A4
20 xx xx JSR @rts12
Clobbers Y, and Z&N; and requires @rts12
6 bytes
08       PHP
28       PLP
EA   ... NOP      × 4
No requirements


16 cycles

5 bytes
EA       NOP
08       PHP       \ × 2
28       PLP       /
No requirements


17 cycles

6 bytes
08       PHP
48       PHA
A5 A5    LDA $A5
68       PLA
28       PLP
No requirements


18 cycles

6 bytes
EA   ... NOP      × 2
08       PHP       \ × 2
28       PLP       /
No requirements


19 cycles

5 bytes
08       PHP
28       PLP
20 xx xx JSR @rts12
Requires @rts12
6 bytes
08       PHP
36 36    ROL $36,X
76 36    ROR $36,X
28       PLP
No requirements


20 cycles

5 bytes
A9 2A    LDA #$2A ;hides 'ROL A'
38       SEC
10 FC    BPL *-2
Clobbers A, Z&N, and C
7 bytes
EA   ... NOP      × 3
08       PHP       \ × 2
28       PLP       /
No requirements


21 cycles

5 bytes
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
90 FD    BCC *-1
Clobbers A, Z&N, and C
A2 04    LDX #4
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
6 bytes
08       PHP       \ × 3
28       PLP       /
No requirements


22 cycles

6 bytes
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
38       SEC
10 FC    BPL *-2
Clobbers A, Z&N, and C
A2 02    LDX #2
EA       NOP
CA       DEX
10 FC    BPL *-2
Clobbers X, and Z&N
A0 03    LDY #3
EA       NOP
88       DEY
D0 FC    BNE *-2
Clobbers Y, and Z&N
7 bytes
08       PHP
BA       TSX
08       PHP
28   ... PLP      × 2
9A       TXS
28       PLP
Clobbers X
08       PHP
C5 C5    CMP $C5
28       PLP
20 xx xx JSR @rts12
Requires @rts12
8 bytes
08       PHP       \ × 2
28       PLP       /
EA   ... NOP      × 4
No requirements


23 cycles

6 bytes
18   ... CLC      × 2
A9 2A    LDA #$2A ;hides 'ROL A'
90 FD    BCC *-1
Clobbers A, Z&N, and C
EA       NOP
A2 04    LDX #4
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
EA       NOP
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
7 bytes
EA       NOP
08       PHP       \ × 3
28       PLP       /
No requirements


24 cycles

4 bytes
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
Clobbers A, Z&N, and C
6 bytes
20 xx xx JSR @rts12× 2
Requires @rts12
7 bytes
A6 A6    LDX $A6
A2 04    LDX #4
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
A4 A4    LDY $A4
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
8 bytes
08       PHP
C5 C5    CMP $C5
28       PLP       \ × 2
08       PHP       /
28       PLP
No requirements


25 cycles

7 bytes
98       TYA
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
A8       TAY
Clobbers A, and Z&N
EA   ... NOP      × 2
A2 04    LDX #4
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
EA   ... NOP      × 2
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
8 bytes
EA   ... NOP      × 2
08       PHP       \ × 3
28       PLP       /
No requirements


26 cycles

5 bytes
18       CLC
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
Clobbers A, Z&N, and C
A2 04    LDX #4
CA       DEX
10 FD    BPL *-1
Clobbers X, and Z&N
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
7 bytes
EA       NOP
20 xx xx JSR @rts12× 2
Requires @rts12
8 bytes
08       PHP
48       PHA
36 36    ROL $36,X
76 36    ROR $36,X
68       PLA
28       PLP
No requirements


27 cycles

6 bytes
A5 A5    LDA $A5
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
Clobbers A, Z&N, and C
7 bytes
48       PHA
A9 2A    LDA #$2A ;hides 'ROL A'
38       SEC
10 FC    BPL *-2
68       PLA
Clobbers Z&N, and C
08       PHP
A9 2A    LDA #$2A ;hides 'ROL A'
38       SEC
10 FC    BPL *-2
28       PLP
Clobbers A
24 2C    BIT <$2C ;hides 'BIT $FDA2'
A2 FD    LDX #253
E8       INX
D0 FA    BNE *-4
Clobbers X, Z&N, and V
24 2C    BIT <$2C ;hides 'BIT $FDA0'
A0 FD    LDY #253
C8       INY
D0 FA    BNE *-4
Clobbers Y, Z&N, and V
A4 AC    LDY <$AC ;hides 'LDY $82A2'
A2 82    LDX #130
CA       DEX
30 FA    BMI *-4
Clobbers X, Y, and Z&N
8 bytes
EA   ... NOP      × 3
A2 04    LDX #4
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
EA   ... NOP      × 3
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
24 24    BIT $24
20 xx xx JSR @rts12× 2
Clobbers Z&N, and V; and requires @rts12
20 xx xx JSR @rts12
08       PHP
BA       TSX
28       PLP
9A       TXS
28       PLP
Clobbers X; and requires @rts12
9 bytes
EA   ... NOP      × 3
08       PHP       \ × 3
28       PLP       /
No requirements


28 cycles

6 bytes
38   ... SEC      × 2
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
Clobbers A, Z&N, and C
EA       NOP
A2 04    LDX #4
CA       DEX
10 FD    BPL *-1
Clobbers X, and Z&N
EA       NOP
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
7 bytes
48       PHA
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
90 FD    BCC *-1
68       PLA
Clobbers Z&N, and C
08       PHP
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
90 FD    BCC *-1
28       PLP
Clobbers A
08       PHP
A2 04    LDX #4
CA       DEX
D0 FD    BNE *-1
28       PLP
Clobbers X
08       PHP
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
28       PLP
Clobbers Y
8 bytes
08       PHP       \ × 4
28       PLP       /
No requirements


29 cycles

6 bytes
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
EA       NOP
90 FC    BCC *-2
Clobbers A, Z&N, and C
A2 04    LDX #4
EA       NOP
CA       DEX
D0 FC    BNE *-2
Clobbers X, and Z&N
A0 04    LDY #4
EA       NOP
88       DEY
D0 FC    BNE *-2
Clobbers Y, and Z&N
8 bytes
48       PHA
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
38       SEC
10 FC    BPL *-2
68       PLA
Clobbers Z&N, and C
08       PHP
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
38       SEC
10 FC    BPL *-2
28       PLP
Clobbers A
08       PHP
A2 02    LDX #2
EA       NOP
CA       DEX
10 FC    BPL *-2
28       PLP
Clobbers X
08       PHP
A0 03    LDY #3
EA       NOP
88       DEY
D0 FC    BNE *-2
28       PLP
Clobbers Y
9 bytes
08       PHP
28       PLP
08       PHP
C5 C5    CMP $C5
28       PLP
20 xx xx JSR @rts12
Requires @rts12
10 bytes
08       PHP
C5 C5    CMP $C5
28       PLP
08       PHP
36 36    ROL $36,X
76 36    ROR $36,X
28       PLP
No requirements


30 cycles

7 bytes
98       TYA
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
A8       TAY
Clobbers A, and Z&N
EA   ... NOP      × 2
A2 04    LDX #4
CA       DEX
10 FD    BPL *-1
Clobbers X, and Z&N
EA   ... NOP      × 2
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
8 bytes
48       PHA
18   ... CLC      × 2
A9 2A    LDA #$2A ;hides 'ROL A'
90 FD    BCC *-1
68       PLA
Clobbers Z&N, and C
08       PHP
18   ... CLC      × 2
A9 2A    LDA #$2A ;hides 'ROL A'
90 FD    BCC *-1
28       PLP
Clobbers A
EA       NOP
08       PHP
A2 04    LDX #4
CA       DEX
D0 FD    BNE *-1
28       PLP
Clobbers X
EA       NOP
08       PHP
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
28       PLP
Clobbers Y
9 bytes
08       PHP
48       PHA
18       CLC
A9 6A    LDA #$6A ;hides 'ROR A'
90 FD    BCC *-1
68       PLA
28       PLP
No requirements


31 cycles

5 bytes
18       CLC
A9 0A    LDA #$0A ;hides 'ASL A'
90 FD    BCC *-1
Clobbers A, Z&N, and C
A2 05    LDX #5
CA       DEX
10 FD    BPL *-1
Clobbers X, and Z&N
A0 06    LDY #6
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
6 bytes
48       PHA
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
68       PLA
Clobbers Z&N, and C
08       PHP
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
28       PLP
Clobbers A
8 bytes
08       PHP
28       PLP
20 xx xx JSR @rts12× 2
Requires @rts12
9 bytes
08       PHP
A6 A6    LDX $A6
A2 04    LDX #4
CA       DEX
D0 FD    BNE *-1
28       PLP
Clobbers X
08       PHP
A4 A4    LDY $A4
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
28       PLP
Clobbers Y
10 bytes
08       PHP
36 36    ROL $36,X \ × 2
76 36    ROR $36,X /
28       PLP
No requirements


32 cycles

6 bytes
A2 05    LDX #5 ;hides 'ORA zp'
CA       DEX ;first loop only
CA       DEX
D0 FB    BNE *-3
Clobbers A, X, and Z&N
A0 05    LDY #5 ;hides 'ORA zp'
88       DEY ;first loop only
88       DEY
D0 FB    BNE *-3
Clobbers A, Y, and Z&N
7 bytes
A9 2A    LDA #$2A ;hides 'ROL A'
EA   ... NOP      × 3
10 FA    BPL *-4
Clobbers A, Z&N, and C
8 bytes
EA       NOP
98       TYA
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
A8       TAY
Clobbers A, and Z&N
A6 A6    LDX $A6
A2 04    LDX #4
EA       NOP
CA       DEX
D0 FC    BNE *-2
Clobbers X, and Z&N
A4 A4    LDY $A4
A0 04    LDY #4
EA       NOP
88       DEY
D0 FC    BNE *-2
Clobbers Y, and Z&N
9 bytes
48       PHA
98       TYA
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
A8       TAY
68       PLA
Clobbers Z&N
08       PHP
98       TYA
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
A8       TAY
28       PLP
Clobbers A
EA   ... NOP      × 2
08       PHP
A2 04    LDX #4
CA       DEX
D0 FD    BNE *-1
28       PLP
Clobbers X
EA   ... NOP      × 2
08       PHP
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
28       PLP
Clobbers Y
10 bytes
08       PHP
48       PHA
18   ... CLC      × 2
A9 6A    LDA #$6A ;hides 'ROR A'
90 FD    BCC *-1
68       PLA
28       PLP
No requirements


33 cycles

6 bytes
18   ... CLC      × 2
A9 0A    LDA #$0A ;hides 'ASL A'
90 FD    BCC *-1
Clobbers A, Z&N, and C
EA       NOP
A2 05    LDX #5
CA       DEX
10 FD    BPL *-1
Clobbers X, and Z&N
EA       NOP
A0 06    LDY #6
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
7 bytes
48       PHA
18       CLC
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
68       PLA
Clobbers Z&N, and C
08       PHP
18       CLC
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
28       PLP
Clobbers A
08       PHP
A2 04    LDX #4
CA       DEX
10 FD    BPL *-1
28       PLP
Clobbers X
08       PHP
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
28       PLP
Clobbers Y
9 bytes
EA       NOP
08       PHP
28       PLP
20 xx xx JSR @rts12× 2
Requires @rts12
10 bytes
08       PHP       \ × 2
28       PLP       /
08       PHP
36 36    ROL $36,X
76 36    ROR $36,X
28       PLP
No requirements


34 cycles

5 bytes
A9 0A    LDA #$0A ;hides 'ASL A'
18       CLC
10 FC    BPL *-2
Clobbers A, Z&N, and C
A0 88    LDY #136 ;hides 'DEY'
88       DEY
30 FC    BMI *-2
Clobbers Y, and Z&N
7 bytes
A6 A6    LDX $A6
A2 05    LDX #5
CA       DEX
10 FD    BPL *-1
Clobbers X, and Z&N
8 bytes
C5 C5    CMP $C5
48       PHA
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
68       PLA
Clobbers Z&N, and C
08       PHP
A5 A5    LDA $A5
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
28       PLP
Clobbers A
9 bytes
08       PHP
48       PHA
A9 2A    LDA #$2A ;hides 'ROL A'
38       SEC
10 FC    BPL *-2
68       PLA
28       PLP
No requirements


35 cycles

6 bytes
A9 2A    LDA #$2A ;hides 'ROL A'
08       PHP
28       PLP
10 FB    BPL *-3
Clobbers A, Z&N, and C
A2 F8    LDX #248 ;hides 'SED'
E8   ... INX      × 2
D0 FB    BNE *-3
Clobbers X, Z&N, and D
A0 88    LDY #136 ;hides 'DEY'
88   ... DEY      × 2
30 FB    BMI *-3
Clobbers Y, and Z&N
7 bytes
98       TYA
A0 06    LDY #6
88       DEY
D0 FD    BNE *-1
A8       TAY
Clobbers A, and Z&N
EA   ... NOP      × 2
A2 05    LDX #5
CA       DEX
10 FD    BPL *-1
Clobbers X, and Z&N
8 bytes
48       PHA
38   ... SEC      × 2
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
68       PLA
Clobbers Z&N, and C
08       PHP
38   ... SEC      × 2
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
28       PLP
Clobbers A
EA       NOP
08       PHP
A2 04    LDX #4
CA       DEX
10 FD    BPL *-1
28       PLP
Clobbers X
EA       NOP
08       PHP
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
28       PLP
Clobbers Y
9 bytes
08       PHP
48       PHA
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
90 FD    BCC *-1
68       PLA
28       PLP
No requirements


36 cycles

5 bytes
A9 E9    LDA #$E9 ;hides 'SBC #$2A'
2A       ROL A ;first loop only
B0 FC    BCS *-2
Clobbers A, Z&N, C, and V
A2 07    LDX #7
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
Clobbers Y, and Z&N
6 bytes
38       SEC
A9 0A    LDA #$0A ;hides 'ASL A'
38       SEC
10 FC    BPL *-2
Clobbers A, Z&N, and C
8 bytes
48       PHA
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
EA       NOP
90 FC    BCC *-2
68       PLA
Clobbers Z&N, and C
08       PHP
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
EA       NOP
90 FC    BCC *-2
28       PLP
Clobbers A
08       PHP
A2 04    LDX #4
EA       NOP
CA       DEX
D0 FC    BNE *-2
28       PLP
Clobbers X
08       PHP
A0 04    LDY #4
EA       NOP
88       DEY
D0 FC    BNE *-2
28       PLP
Clobbers Y
9 bytes
20 xx xx JSR @rts12× 3
Requires @rts12
10 bytes
08       PHP
48       PHA
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
38       SEC
10 FC    BPL *-2
68       PLA
28       PLP
No requirements


37 cycles

7 bytes
A5 A5    LDA $A5
A9 0A    LDA #$0A ;hides 'ASL A'
18       CLC
10 FC    BPL *-2
Clobbers A, Z&N, and C
A2 04    LDX #4
EA   ... NOP      × 2
CA       DEX
D0 FB    BNE *-3
Clobbers X, and Z&N
A0 04    LDY #4
EA   ... NOP      × 2
88       DEY
D0 FB    BNE *-3
Clobbers Y, and Z&N
8 bytes
EA       NOP
98       TYA
A0 06    LDY #6
88       DEY
D0 FD    BNE *-1
A8       TAY
Clobbers A, and Z&N
9 bytes
48       PHA
98       TYA
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
A8       TAY
68       PLA
Clobbers Z&N
08       PHP
98       TYA
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
A8       TAY
28       PLP
Clobbers A
EA   ... NOP      × 2
08       PHP
A2 04    LDX #4
CA       DEX
10 FD    BPL *-1
28       PLP
Clobbers X
EA   ... NOP      × 2
08       PHP
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
28       PLP
Clobbers Y
10 bytes
08       PHP
48       PHA
18   ... CLC      × 2
A9 2A    LDA #$2A ;hides 'ROL A'
90 FD    BCC *-1
68       PLA
28       PLP
No requirements


38 cycles

6 bytes
38       SEC
A9 69    LDA #$69 ;hides 'ADC #$EA'
EA       NOP ;first loop only
B0 FC    BCS *-2
Clobbers A, Z&N, C, and V
EA       NOP
A2 07    LDX #7
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
EA       NOP
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
Clobbers Y, and Z&N
7 bytes
48       PHA
18       CLC
A9 0A    LDA #$0A ;hides 'ASL A'
90 FD    BCC *-1
68       PLA
Clobbers Z&N, and C
08       PHP
18       CLC
A9 0A    LDA #$0A ;hides 'ASL A'
90 FD    BCC *-1
28       PLP
Clobbers A
08       PHP
A2 05    LDX #5
CA       DEX
10 FD    BPL *-1
28       PLP
Clobbers X
08       PHP
A0 06    LDY #6
88       DEY
D0 FD    BNE *-1
28       PLP
Clobbers Y
8 bytes
08       PHP
48       PHA
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
68       PLA
28       PLP
No requirements


39 cycles

4 bytes
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
Clobbers A, Z&N, and C
7 bytes
A6 A6    LDX $A6
A2 07    LDX #7
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
A4 A4    LDY $A4
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
Clobbers Y, and Z&N
8 bytes
98       TYA
A0 88    LDY #136 ;hides 'DEY'
88   ... DEY      × 2
30 FB    BMI *-3
A8       TAY
Clobbers A, and Z&N
08       PHP
A2 05    LDX #5 ;hides 'ORA zp'
CA       DEX ;first loop only
CA       DEX
D0 FB    BNE *-3
28       PLP
Clobbers A, and X
08       PHP
A0 05    LDY #5 ;hides 'ORA zp'
88       DEY ;first loop only
88       DEY
D0 FB    BNE *-3
28       PLP
Clobbers A, and Y
9 bytes
48       PHA
A9 2A    LDA #$2A ;hides 'ROL A'
EA   ... NOP      × 3
10 FA    BPL *-4
68       PLA
Clobbers Z&N, and C
08       PHP
A9 2A    LDA #$2A ;hides 'ROL A'
EA   ... NOP      × 3
10 FA    BPL *-4
28       PLP
Clobbers A
10 bytes
EA       NOP
48       PHA
98       TYA
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
A8       TAY
68       PLA
Clobbers Z&N
08       PHP
A6 A6    LDX $A6
A2 04    LDX #4
EA       NOP
CA       DEX
D0 FC    BNE *-2
28       PLP
Clobbers X
08       PHP
A4 A4    LDY $A4
A0 04    LDY #4
EA       NOP
88       DEY
D0 FC    BNE *-2
28       PLP
Clobbers Y
11 bytes
08       PHP
48       PHA
98       TYA
A0 04    LDY #4
88       DEY
D0 FD    BNE *-1
A8       TAY
68       PLA
28       PLP
No requirements


40 cycles

6 bytes
A2 05    LDX #5 ;hides 'ORA zp'
EA       NOP
CA       DEX
D0 FB    BNE *-3
Clobbers A, X, and Z&N
A0 05    LDY #5 ;hides 'ORA zp'
EA       NOP
88       DEY
D0 FB    BNE *-3
Clobbers A, Y, and Z&N
7 bytes
98       TYA
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
A8       TAY
Clobbers A, and Z&N
EA   ... NOP      × 2
A2 07    LDX #7
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
EA   ... NOP      × 2
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
Clobbers Y, and Z&N
8 bytes
48       PHA
18   ... CLC      × 2
A9 0A    LDA #$0A ;hides 'ASL A'
90 FD    BCC *-1
68       PLA
Clobbers Z&N, and C
08       PHP
18   ... CLC      × 2
A9 0A    LDA #$0A ;hides 'ASL A'
90 FD    BCC *-1
28       PLP
Clobbers A
EA       NOP
08       PHP
A2 05    LDX #5
CA       DEX
10 FD    BPL *-1
28       PLP
Clobbers X
EA       NOP
08       PHP
A0 06    LDY #6
88       DEY
D0 FD    BNE *-1
28       PLP
Clobbers Y
9 bytes
08       PHP
48       PHA
18       CLC
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
68       PLA
28       PLP
No requirements


41 cycles

5 bytes
38       SEC
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
Clobbers A, Z&N, and C
A2 08    LDX #8
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
A0 08    LDY #8
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
7 bytes
48       PHA
A9 0A    LDA #$0A ;hides 'ASL A'
18       CLC
10 FC    BPL *-2
68       PLA
Clobbers Z&N, and C
08       PHP
A9 0A    LDA #$0A ;hides 'ASL A'
18       CLC
10 FC    BPL *-2
28       PLP
Clobbers A
08       PHP
A0 88    LDY #136 ;hides 'DEY'
88       DEY
30 FC    BMI *-2
28       PLP
Clobbers Y
9 bytes
08       PHP
A6 A6    LDX $A6
A2 05    LDX #5
CA       DEX
10 FD    BPL *-1
28       PLP
Clobbers X
10 bytes
08       PHP
48       PHA
A5 A5    LDA $A5
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
68       PLA
28       PLP
No requirements


42 cycles

6 bytes
A5 A5    LDA $A5
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
Clobbers A, Z&N, and C
7 bytes
EA       NOP
A2 05    LDX #5 ;hides 'ORA zp'
EA       NOP
CA       DEX
D0 FB    BNE *-3
Clobbers A, X, and Z&N
EA       NOP
A0 05    LDY #5 ;hides 'ORA zp'
EA       NOP
88       DEY
D0 FB    BNE *-3
Clobbers A, Y, and Z&N
8 bytes
48       PHA
A9 2A    LDA #$2A ;hides 'ROL A'
08       PHP
28       PLP
10 FB    BPL *-3
68       PLA
Clobbers Z&N, and C
08       PHP
A9 2A    LDA #$2A ;hides 'ROL A'
08       PHP
28       PLP
10 FB    BPL *-3
28       PLP
Clobbers A
08       PHP
A2 F8    LDX #248 ;hides 'SED'
E8   ... INX      × 2
D0 FB    BNE *-3
28       PLP
Clobbers X
08       PHP
A0 88    LDY #136 ;hides 'DEY'
88   ... DEY      × 2
30 FB    BMI *-3
28       PLP
Clobbers Y
9 bytes
48       PHA
98       TYA
A0 06    LDY #6
88       DEY
D0 FD    BNE *-1
A8       TAY
68       PLA
Clobbers Z&N
10 bytes
08       PHP
48       PHA
38   ... SEC      × 2
A9 0A    LDA #$0A ;hides 'ASL A'
10 FD    BPL *-1
68       PLA
28       PLP
No requirements


43 cycles

6 bytes
38   ... SEC      × 2
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
Clobbers A, Z&N, and C
A2 05    LDX #5
EA       NOP
CA       DEX
10 FC    BPL *-2
Clobbers X, and Z&N
A0 06    LDY #6
EA       NOP
88       DEY
D0 FC    BNE *-2
Clobbers Y, and Z&N
7 bytes
48       PHA
A9 E9    LDA #$E9 ;hides 'SBC #$2A'
2A       ROL A ;first loop only
B0 FC    BCS *-2
68       PLA
Clobbers Z&N, C, and V
08       PHP
A9 E9    LDA #$E9 ;hides 'SBC #$2A'
2A       ROL A ;first loop only
B0 FC    BCS *-2
28       PLP
Clobbers A
08       PHP
A2 07    LDX #7
CA       DEX
D0 FD    BNE *-1
28       PLP
Clobbers X
08       PHP
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
28       PLP
Clobbers Y
8 bytes
48       PHA
38       SEC
A9 0A    LDA #$0A ;hides 'ASL A'
38       SEC
10 FC    BPL *-2
68       PLA
Clobbers Z&N, and C
10 bytes
08       PHP
48       PHA
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
EA       NOP
90 FC    BCC *-2
68       PLA
28       PLP
No requirements


44 cycles

6 bytes
A9 0A    LDA #$0A ;hides 'ASL A'
EA   ... NOP      × 2
10 FB    BPL *-3
Clobbers A, Z&N, and C
A0 88    LDY #136 ;hides 'DEY'
EA       NOP
88       DEY
30 FB    BMI *-3
Clobbers Y, and Z&N
7 bytes
A6 A6    LDX $A6
A2 08    LDX #8
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
9 bytes
C5 C5    CMP $C5
48       PHA
A9 0A    LDA #$0A ;hides 'ASL A'
18       CLC
10 FC    BPL *-2
68       PLA
Clobbers Z&N, and C
08       PHP
A5 A5    LDA $A5
A9 0A    LDA #$0A ;hides 'ASL A'
18       CLC
10 FC    BPL *-2
28       PLP
Clobbers A
08       PHP
A2 04    LDX #4
EA   ... NOP      × 2
CA       DEX
D0 FB    BNE *-3
28       PLP
Clobbers X
08       PHP
A0 04    LDY #4
EA   ... NOP      × 2
88       DEY
D0 FB    BNE *-3
28       PLP
Clobbers Y
10 bytes
EA       NOP
48       PHA
98       TYA
A0 06    LDY #6
88       DEY
D0 FD    BNE *-1
A8       TAY
68       PLA
Clobbers Z&N
11 bytes
08       PHP
48       PHA
98       TYA
A0 05    LDY #5
88       DEY
D0 FD    BNE *-1
A8       TAY
68       PLA
28       PLP
No requirements


45 cycles

7 bytes
98       TYA
A0 08    LDY #8
88       DEY
D0 FD    BNE *-1
A8       TAY
Clobbers A, and Z&N
EA   ... NOP      × 2
A2 08    LDX #8
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
EA   ... NOP      × 2
A0 08    LDY #8
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
8 bytes
48       PHA
38       SEC
A9 69    LDA #$69 ;hides 'ADC #$EA'
EA       NOP ;first loop only
B0 FC    BCS *-2
68       PLA
Clobbers Z&N, C, and V
08       PHP
38       SEC
A9 69    LDA #$69 ;hides 'ADC #$EA'
EA       NOP ;first loop only
B0 FC    BCS *-2
28       PLP
Clobbers A
EA       NOP
08       PHP
A2 07    LDX #7
CA       DEX
D0 FD    BNE *-1
28       PLP
Clobbers X
EA       NOP
08       PHP
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
28       PLP
Clobbers Y
9 bytes
08       PHP
48       PHA
18       CLC
A9 0A    LDA #$0A ;hides 'ASL A'
90 FD    BCC *-1
68       PLA
28       PLP
No requirements


46 cycles

5 bytes
A2 08    LDX #8
CA       DEX
10 FD    BPL *-1
Clobbers X, and Z&N
A0 09    LDY #9
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
6 bytes
48       PHA
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
68       PLA
Clobbers Z&N, and C
08       PHP
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
28       PLP
Clobbers A
9 bytes
08       PHP
A6 A6    LDX $A6
A2 07    LDX #7
CA       DEX
D0 FD    BNE *-1
28       PLP
Clobbers X
08       PHP
A4 A4    LDY $A4
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
28       PLP
Clobbers Y
10 bytes
48       PHA
98       TYA
A0 88    LDY #136 ;hides 'DEY'
88   ... DEY      × 2
30 FB    BMI *-3
A8       TAY
68       PLA
Clobbers Z&N
11 bytes
08       PHP
48       PHA
A9 2A    LDA #$2A ;hides 'ROL A'
EA   ... NOP      × 3
10 FA    BPL *-4
68       PLA
28       PLP
No requirements


47 cycles

8 bytes
98       TYA
A0 06    LDY #6
EA       NOP
88       DEY
D0 FC    BNE *-2
A8       TAY
Clobbers A, and Z&N
EA   ... NOP      × 3
A2 08    LDX #8
CA       DEX
D0 FD    BNE *-1
Clobbers X, and Z&N
08       PHP
A2 05    LDX #5 ;hides 'ORA zp'
EA       NOP
CA       DEX
D0 FB    BNE *-3
28       PLP
Clobbers A, and X
EA   ... NOP      × 3
A0 08    LDY #8
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
08       PHP
A0 05    LDY #5 ;hides 'ORA zp'
EA       NOP
88       DEY
D0 FB    BNE *-3
28       PLP
Clobbers A, and Y
9 bytes
48       PHA
98       TYA
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
A8       TAY
68       PLA
Clobbers Z&N
08       PHP
98       TYA
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
A8       TAY
28       PLP
Clobbers A
EA   ... NOP      × 2
08       PHP
A2 07    LDX #7
CA       DEX
D0 FD    BNE *-1
28       PLP
Clobbers X
EA   ... NOP      × 2
08       PHP
A0 06    LDY #6
88       DEY
10 FD    BPL *-1
28       PLP
Clobbers Y
10 bytes
08       PHP
48       PHA
18   ... CLC      × 2
A9 0A    LDA #$0A ;hides 'ASL A'
90 FD    BCC *-1
68       PLA
28       PLP
No requirements


48 cycles

6 bytes
EA       NOP
A2 08    LDX #8
CA       DEX
10 FD    BPL *-1
Clobbers X, and Z&N
EA       NOP
A0 09    LDY #9
88       DEY
D0 FD    BNE *-1
Clobbers Y, and Z&N
7 bytes
48       PHA
38       SEC
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
68       PLA
Clobbers Z&N, and C
08       PHP
38       SEC
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
28       PLP
Clobbers A
08       PHP
A2 08    LDX #8
CA       DEX
D0 FD    BNE *-1
28       PLP
Clobbers X
08       PHP
A0 08    LDY #8
88       DEY
D0 FD    BNE *-1
28       PLP
Clobbers Y
9 bytes
08       PHP
48       PHA
A9 0A    LDA #$0A ;hides 'ASL A'
18       CLC
10 FC    BPL *-2
68       PLA
28       PLP
No requirements


49 cycles

4 bytes
A0 88    LDY #136 ;hides 'DEY'
30 FD    BMI *-1
Clobbers Y, and Z&N
7 bytes
18       CLC
A9 2A    LDA #$2A ;hides 'ROL A'
08       PHP
28       PLP
90 FB    BCC *-3
Clobbers A, Z&N, and C
A6 A6    LDX $A6
A2 08    LDX #8
CA       DEX
10 FD    BPL *-1
Clobbers X, and Z&N
8 bytes
C5 C5    CMP $C5
48       PHA
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
68       PLA
Clobbers Z&N, and C
08       PHP
A5 A5    LDA $A5
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
28       PLP
Clobbers A
10 bytes
08       PHP
48       PHA
A9 2A    LDA #$2A ;hides 'ROL A'
08       PHP
28       PLP
10 FB    BPL *-3
68       PLA
28       PLP
No requirements


50 cycles

6 bytes
A9 E9    LDA #$E9 ;hides 'SBC #$2A'
2A       ROL A ;first loop only
EA       NOP
B0 FB    BCS *-3
Clobbers A, Z&N, C, and V
A2 07    LDX #7
EA       NOP
CA       DEX
D0 FC    BNE *-2
Clobbers X, and Z&N
A0 06    LDY #6
EA       NOP
88       DEY
10 FC    BPL *-2
Clobbers Y, and Z&N
7 bytes
98       TYA
A0 09    LDY #9
88       DEY
D0 FD    BNE *-1
A8       TAY
Clobbers A, and Z&N
8 bytes
48       PHA
38   ... SEC      × 2
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
68       PLA
Clobbers Z&N, and C
08       PHP
38   ... SEC      × 2
A9 4A    LDA #$4A ;hides 'LSR A'
D0 FD    BNE *-1
28       PLP
Clobbers A
08       PHP
A2 05    LDX #5
EA       NOP
CA       DEX
10 FC    BPL *-2
28       PLP
Clobbers X
08       PHP
A0 06    LDY #6
EA       NOP
88       DEY
D0 FC    BNE *-2
28       PLP
Clobbers Y
9 bytes
08       PHP
48       PHA
A9 E9    LDA #$E9 ;hides 'SBC #$2A'
2A       ROL A ;first loop only
B0 FC    BCS *-2
68       PLA
28       PLP
No requirements


Sanity checks

It is possible to verify on compile time that no page wrap occurs, by replacing all branches with these macros:

.macro branch_check opc, dest
    opc dest
    .assert >* = >(dest), warning, "branch_check: failed, crosses page"
.endmacro
.macro bccnw dest
        branch_check bcc, dest
.endmacro
.macro bcsnw dest
        branch_check bcs, dest
.endmacro
.macro beqnw dest
        branch_check beq, dest
.endmacro
.macro bnenw dest
        branch_check bne, dest
.endmacro
.macro bminw dest
        branch_check bmi, dest
.endmacro
.macro bplnw dest
        branch_check bpl, dest
.endmacro
.macro bvcnw dest
        branch_check bvc, dest
.endmacro
.macro bvsnw dest
        branch_check bvs, dest
.endmacro

See also

  • Cycle counting
  • Delay code for functions that produce runtime-determined amount of delay
  • Bisqwit’s “vending machine” for producing a ca65-compatible delay_n macro for arbitrary number of cycles, with more fine-grained configurable constraints: http://bisqwit.iki.fi/utils/nesdelay.php The samples on this page are excerpts from files generated by this online tool.