<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://sneslab.net/mw/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xetheria</id>
	<title>SnesLab - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://sneslab.net/mw/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xetheria"/>
	<link rel="alternate" type="text/html" href="https://sneslab.net/wiki/Special:Contributions/Xetheria"/>
	<updated>2026-06-24T19:24:07Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=TCALL_(SPC700)&amp;diff=21264</id>
		<title>TCALL (SPC700)</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=TCALL_(SPC700)&amp;diff=21264"/>
		<updated>2026-06-06T12:10:04Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: capitalize other L&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Vector Address&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|01&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFDE&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|11&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFDC&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|21&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFDA&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|31&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFD8&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|41&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFD6&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|51&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFD4&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|61&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFD2&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|71&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFD0&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|81&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFCE&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|91&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFCC&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|A1&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFCA&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|B1&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFC8&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|C1&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFC6&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|D1&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFC4&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|E1&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFC2&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 3)&lt;br /&gt;
|F1&lt;br /&gt;
|1 byte&lt;br /&gt;
|8 cycles&lt;br /&gt;
|$FFC0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[Direct Page Flag|P]]&lt;br /&gt;
|[[Break Flag|B]]&lt;br /&gt;
|[[Half-Carry Flag|H]]&lt;br /&gt;
|[[Interrupt Enable Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TCALL&#039;&#039;&#039; (Table CALL) is an [[SPC700]] instruction that calls a subroutine whose 16-bit address is stored in the [[uppermost page]].  The low byte of the address of the vector (pointer to subroutine) is a function of the high nybble of the opcode, equal to $DE - n*2.  The high byte of the vector address is always $FF.&lt;br /&gt;
&lt;br /&gt;
No flags are affected.&lt;br /&gt;
&lt;br /&gt;
=== Syntax ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
TCALL n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where n is the &#039;&#039;&#039;vector call number&#039;&#039;&#039;, a decimal integer from 0 to 15, which becomes the high nybble of the opcode.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[CALL]]&lt;br /&gt;
* [[PCALL]]&lt;br /&gt;
* [[RET]]&lt;br /&gt;
* [[SPC700/IPL ROM]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* Official Nintendo documentation on TCALL: Table C-16 [https://archive.org/details/SNESDevManual/book1/page/n234 Appendix C-9]&lt;br /&gt;
* [https://www.romhacking.net/documents/197 anomie&#039;s SPC700 doc]&lt;br /&gt;
* https://forums.nesdev.org/viewtopic.php?t=13313&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:SPC700]]&lt;br /&gt;
[[Category:Subroutine Call Return Commands]]&lt;br /&gt;
[[Category:One-byte Instructions]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Stack&amp;diff=21261</id>
		<title>Stack</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Stack&amp;diff=21261"/>
		<updated>2026-05-21T21:36:13Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: no stack base pointer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Stack&#039;&#039;&#039; is a LIFO (last-in, first-out) buffer which remembers the state of subroutines that are currently executing.&lt;br /&gt;
&lt;br /&gt;
On the [[65c816]], the stack is always in [[bank]] zero.&amp;lt;sup&amp;gt;[3]&amp;lt;/sup&amp;gt;  It can be thousands of bytes deep.&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In [[emulation mode]] it wraps within page one.&amp;lt;sup&amp;gt;[2]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The stack grows towards zero, but the most recently pushed byte is nontheless called the top of the stack.&amp;lt;sup&amp;gt;[4]&amp;lt;/sup&amp;gt;  These instructions push things to the stack:&lt;br /&gt;
&lt;br /&gt;
* [[PEA]]&lt;br /&gt;
* [[PEI]]&lt;br /&gt;
* [[PER]]&lt;br /&gt;
* [[PHA]]&lt;br /&gt;
* [[PHB]]&lt;br /&gt;
* [[PHD]]&lt;br /&gt;
* [[PHK]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[PHX]]&lt;br /&gt;
* [[PHY]]&lt;br /&gt;
* [[JSR]]&lt;br /&gt;
* [[JSL]]&lt;br /&gt;
* [[COP]]&lt;br /&gt;
* [[BRK]]&lt;br /&gt;
&lt;br /&gt;
PL* instructions take one cycle more than their PH* counterparts because they have to increment the stack pointer to point to the top element before it can be pulled, whereas push instructions pipeline the decrement of SP so that it overlaps the opcode fetch of the next instruction.  These instructions pull things from the stack:&lt;br /&gt;
&lt;br /&gt;
* [[PLA]]&lt;br /&gt;
* [[PLB]]&lt;br /&gt;
* [[PLD]]&lt;br /&gt;
* [[PLP]]&lt;br /&gt;
* [[PLX]]&lt;br /&gt;
* [[PLY]]&lt;br /&gt;
* [[RTS]]&lt;br /&gt;
* [[RTL]]&lt;br /&gt;
* [[RTI]]&lt;br /&gt;
&lt;br /&gt;
Note the lack of [[PLK]].  PHS and PLS similarly do not exist, nor do any instructions performing the inverse of PEA, PEI, or PER.  Unlike x86, there is also no stack base pointer.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[Stack Pointer]]&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
# Wilson, Garth. https://wilsonminesco.com/816myths&lt;br /&gt;
# Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#5.1.1&lt;br /&gt;
# section 2.11 of 65c816 datasheet: https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf&lt;br /&gt;
# [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/33 page 33]&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Buffers]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=COP&amp;diff=21260</id>
		<title>COP</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=COP&amp;diff=21260"/>
		<updated>2026-05-21T06:53:17Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: Undo revision 21257 by Xetheria (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Addressing|Stack]] (Interrupt)&lt;br /&gt;
|02&lt;br /&gt;
|2 bytes&lt;br /&gt;
|8 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[N Flag|N]]&lt;br /&gt;
|[[V Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[D Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Z Flag|Z]]&lt;br /&gt;
|[[C Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;COP&#039;&#039;&#039; (Co-Processor) is a [[65c816]] instruction designed to run a co-processor command.  COP triggers a software interrupt and control is routed to the COP handler, whose address is stored in the COP vector at $00:FFE4 (in [[native mode]] anyway, in emulation mode $FFF4 is used instead).  The byte following the opcode is called the [[signature byte]] and is required by assemblers:&lt;br /&gt;
* Signature bytes of 00h to 7Fh can be programmer-defined&lt;br /&gt;
* Signature bytes of 80h to FFh are reserved for future microprocessors by the [https://www.westerndesigncenter.com/ Western Design Center]&amp;lt;sup&amp;gt;[3]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The state of the [[interrupt disable flag]] has no effect on the behavior of COP although it will be set after COP runs.&lt;br /&gt;
&lt;br /&gt;
Some examples of the kinds of microprocessors COP could be used to communicate with include:&lt;br /&gt;
* floating point&lt;br /&gt;
* graphics&lt;br /&gt;
&lt;br /&gt;
The [[PBR]] is cleared, but in native mode its previous value is pushed to the [[stack]].&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
COP sig&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Skipped ====&lt;br /&gt;
* COP takes one fewer cycle in [[emulation mode]] as it doesn&#039;t need to push the [[program counter bank register]] to the [[stack]].&lt;br /&gt;
&lt;br /&gt;
[[File:cop.png]]&lt;br /&gt;
&lt;br /&gt;
COP is not really used for anything on the SNES.&amp;lt;sup&amp;gt;[7]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[BRK]]&lt;br /&gt;
* [[RTI]]&lt;br /&gt;
* [[WDM]]&lt;br /&gt;
* [[Enhancement Chips]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
# [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/447 page 447] on COP&lt;br /&gt;
# [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n145 page 135] on COP&lt;br /&gt;
# section 7.15 of 65c816 datasheet&lt;br /&gt;
# snes9x implementation of COP: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L2738&lt;br /&gt;
# https://ersanio.gitbook.io/assembly-for-the-snes/deep-dives/misc&lt;br /&gt;
# https://undisbeliever.net/snesdev/65816-opcodes.html#software-interrupts&lt;br /&gt;
# https://forums.nesdev.org/viewtopic.php?p=176406#p176406&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:65c816 additions]]&lt;br /&gt;
[[Category:Two-byte Instructions]]&lt;br /&gt;
[[Category:Single Admode Mnemonics]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=BRK&amp;diff=21259</id>
		<title>BRK</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=BRK&amp;diff=21259"/>
		<updated>2026-05-21T06:51:14Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: Undo revision 21258 by Xetheria (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Addressing|Stack]] (Interrupt)&lt;br /&gt;
|00&lt;br /&gt;
|2 bytes&lt;br /&gt;
|8 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]] / [[Break Flag|B]]&lt;br /&gt;
|[[D Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|[[65c816 native mode]]&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|+&lt;br /&gt;
|[[6502 emulation mode]]&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BRK&#039;&#039;&#039; (Break) is a 65x instruction that triggers a non-maskable software interrupt ([[Non-Maskable Interrupt|NMI]]).  The byte following the opcode is called the [[signature byte]].  The state of the [[interrupt disable flag]] has no effect on the behavior of BRK although it will be set after BRK runs.&lt;br /&gt;
&lt;br /&gt;
In [[native mode]] the [[program bank register]] is pushed to the [[stack]].  Then the [[program counter]] is incremented by two and then pushed to the stack.  Then the [[status register]] (with the [[break flag]] set, if in emulation mode) is pushed to the stack.  Then the interrupt disable flag is set.  In native mode, the program bank register is then cleared.&lt;br /&gt;
&lt;br /&gt;
Control is routed to the BRK handler, whose address is stored at the BRK vector:&lt;br /&gt;
* In native mode, this vector is at $00:FFE6.&lt;br /&gt;
* In emulation mode, this vector is at $FFFE.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BRK&lt;br /&gt;
BRK sig&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the signature byte was omitted from the assembler source, then it ends up serving double duty as the opcode of the next instruction.  In this case the [[interrupt handler]] must decrement the [[return address]] on the [[stack]] so that the eventual [[RTI]] does not cause [[derailment]].&lt;br /&gt;
&lt;br /&gt;
[[File:brk.png]]&lt;br /&gt;
&lt;br /&gt;
BRK used to be considered a one-byte instruction in an early datasheet.  On the NMOS 6502, BRK does not affect the decimal flag, but this likely only affects porting code from systems other than the NES because the NES does not have decimal mode anyway.&lt;br /&gt;
&lt;br /&gt;
==== Cycle Skipped ====&lt;br /&gt;
* BRK takes one fewer cycle in [[emulation mode]] as it doesn&#039;t need to push the [[program counter bank register]] to the [[stack]].&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[RTI]]&lt;br /&gt;
* [[BRK (SPC700)]]&lt;br /&gt;
* [[NMI]]&lt;br /&gt;
* [[IRQ]]&lt;br /&gt;
* [[COP]]&lt;br /&gt;
* [[WDM]]&lt;br /&gt;
* [[CLD]]&lt;br /&gt;
* [[SEI]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/436 page 436] on BRK&lt;br /&gt;
* Figure 13.3, Break Signature Byte Illustration, lbid, [https://archive.org/details/0893037893ProgrammingThe65816/page/n282 page 256]&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n136 page 126] on BRK&lt;br /&gt;
* 9.11 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n164 page 144] on BRK&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n265 page 252] on BRK&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n98 page 3-49] on BRK&lt;br /&gt;
* snes9x implementation of BRK: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L2547&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#BRK&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c02opcodes.html#6&lt;br /&gt;
* https://undisbeliever.net/snesdev/65816-opcodes.html#software-interrupts&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Two-byte Instructions]]&lt;br /&gt;
[[Category:Single Admode Mnemonics]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=BRK&amp;diff=21258</id>
		<title>BRK</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=BRK&amp;diff=21258"/>
		<updated>2026-05-21T06:39:59Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* External Links */ de n&amp;#039;d page number&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Addressing|Stack]] (Interrupt)&lt;br /&gt;
|00&lt;br /&gt;
|2 bytes&lt;br /&gt;
|8 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]] / [[Break Flag|B]]&lt;br /&gt;
|[[D Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|[[65c816 native mode]]&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|+&lt;br /&gt;
|[[6502 emulation mode]]&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BRK&#039;&#039;&#039; (Break) is a 65x instruction that triggers a non-maskable software interrupt ([[Non-Maskable Interrupt|NMI]]).  The byte following the opcode is called the [[signature byte]].  The state of the [[interrupt disable flag]] has no effect on the behavior of BRK although it will be set after BRK runs.&lt;br /&gt;
&lt;br /&gt;
In [[native mode]] the [[program bank register]] is pushed to the [[stack]].  Then the [[program counter]] is incremented by two and then pushed to the stack.  Then the [[status register]] (with the [[break flag]] set, if in emulation mode) is pushed to the stack.  Then the interrupt disable flag is set.  In native mode, the program bank register is then cleared.&lt;br /&gt;
&lt;br /&gt;
Control is routed to the BRK handler, whose address is stored at the BRK vector:&lt;br /&gt;
* In native mode, this vector is at $00:FFE6.&lt;br /&gt;
* In emulation mode, this vector is at $FFFE.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BRK&lt;br /&gt;
BRK sig&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the signature byte was omitted from the assembler source, then it ends up serving double duty as the opcode of the next instruction.  In this case the [[interrupt handler]] must decrement the [[return address]] on the [[stack]] so that the eventual [[RTI]] does not cause [[derailment]].&lt;br /&gt;
&lt;br /&gt;
[[File:brk.png]]&lt;br /&gt;
&lt;br /&gt;
BRK used to be considered a one-byte instruction in an early datasheet.  On the NMOS 6502, BRK does not affect the decimal flag, but this likely only affects porting code from systems other than the NES because the NES does not have decimal mode anyway.&lt;br /&gt;
&lt;br /&gt;
==== Cycle Skipped ====&lt;br /&gt;
* BRK takes one fewer cycle in [[emulation mode]] as it doesn&#039;t need to push the [[program counter bank register]] to the [[stack]].&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[RTI]]&lt;br /&gt;
* [[BRK (SPC700)]]&lt;br /&gt;
* [[NMI]]&lt;br /&gt;
* [[IRQ]]&lt;br /&gt;
* [[COP]]&lt;br /&gt;
* [[WDM]]&lt;br /&gt;
* [[CLD]]&lt;br /&gt;
* [[SEI]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/436 page 436] on BRK&lt;br /&gt;
* Figure 13.3, Break Signature Byte Illustration, lbid, [https://archive.org/details/0893037893ProgrammingThe65816/page/n282 page 256]&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/126 page 126] on BRK&lt;br /&gt;
* 9.11 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n164 page 144] on BRK&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n265 page 252] on BRK&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n98 page 3-49] on BRK&lt;br /&gt;
* snes9x implementation of BRK: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L2547&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#BRK&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c02opcodes.html#6&lt;br /&gt;
* https://undisbeliever.net/snesdev/65816-opcodes.html#software-interrupts&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Two-byte Instructions]]&lt;br /&gt;
[[Category:Single Admode Mnemonics]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=COP&amp;diff=21257</id>
		<title>COP</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=COP&amp;diff=21257"/>
		<updated>2026-05-21T06:37:55Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* External Links */ de n&amp;#039;d page number&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Addressing|Stack]] (Interrupt)&lt;br /&gt;
|02&lt;br /&gt;
|2 bytes&lt;br /&gt;
|8 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[N Flag|N]]&lt;br /&gt;
|[[V Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[D Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Z Flag|Z]]&lt;br /&gt;
|[[C Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;COP&#039;&#039;&#039; (Co-Processor) is a [[65c816]] instruction designed to run a co-processor command.  COP triggers a software interrupt and control is routed to the COP handler, whose address is stored in the COP vector at $00:FFE4 (in [[native mode]] anyway, in emulation mode $FFF4 is used instead).  The byte following the opcode is called the [[signature byte]] and is required by assemblers:&lt;br /&gt;
* Signature bytes of 00h to 7Fh can be programmer-defined&lt;br /&gt;
* Signature bytes of 80h to FFh are reserved for future microprocessors by the [https://www.westerndesigncenter.com/ Western Design Center]&amp;lt;sup&amp;gt;[3]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The state of the [[interrupt disable flag]] has no effect on the behavior of COP although it will be set after COP runs.&lt;br /&gt;
&lt;br /&gt;
Some examples of the kinds of microprocessors COP could be used to communicate with include:&lt;br /&gt;
* floating point&lt;br /&gt;
* graphics&lt;br /&gt;
&lt;br /&gt;
The [[PBR]] is cleared, but in native mode its previous value is pushed to the [[stack]].&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
COP sig&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Skipped ====&lt;br /&gt;
* COP takes one fewer cycle in [[emulation mode]] as it doesn&#039;t need to push the [[program counter bank register]] to the [[stack]].&lt;br /&gt;
&lt;br /&gt;
[[File:cop.png]]&lt;br /&gt;
&lt;br /&gt;
COP is not really used for anything on the SNES.&amp;lt;sup&amp;gt;[7]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[BRK]]&lt;br /&gt;
* [[RTI]]&lt;br /&gt;
* [[WDM]]&lt;br /&gt;
* [[Enhancement Chips]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
# [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/447 page 447] on COP&lt;br /&gt;
# [[Labiak]], [https://archive.org/details/Programming_the_65816/page/135 page 135] on COP&lt;br /&gt;
# section 7.15 of 65c816 datasheet&lt;br /&gt;
# snes9x implementation of COP: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L2738&lt;br /&gt;
# https://ersanio.gitbook.io/assembly-for-the-snes/deep-dives/misc&lt;br /&gt;
# https://undisbeliever.net/snesdev/65816-opcodes.html#software-interrupts&lt;br /&gt;
# https://forums.nesdev.org/viewtopic.php?p=176406#p176406&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:65c816 additions]]&lt;br /&gt;
[[Category:Two-byte Instructions]]&lt;br /&gt;
[[Category:Single Admode Mnemonics]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Pixel_Processing_Unit&amp;diff=21200</id>
		<title>Pixel Processing Unit</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Pixel_Processing_Unit&amp;diff=21200"/>
		<updated>2026-05-15T08:10:51Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: created page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#redirect [[Picture Processing Unit]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=BIT&amp;diff=21199</id>
		<title>BIT</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=BIT&amp;diff=21199"/>
		<updated>2026-05-15T08:01:49Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: make effective address plus one super clear&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|89&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|2C&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|24&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|3C&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|34&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|Addressing Mode&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|+&lt;br /&gt;
|other&lt;br /&gt;
|N&lt;br /&gt;
|V&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BIT&#039;&#039;&#039; is a 65x instruction that performs a logical AND operation between the [[accumulator]] and memory without storing the conjunction.  If the conjunction is zero, the [[zero flag]] is set, otherwise it is cleared.&lt;br /&gt;
&lt;br /&gt;
The size of the accumulator determines whether this is an 8 or 16 bit operation. If 16-bit and not using [[immediate addressing]], the low-order byte is located at the effective address and the high-order byte at the effective address plus one.&lt;br /&gt;
&lt;br /&gt;
Except in [[immediate addressing]], the most significant bit of the data located at the effective address (or effective address plus one) is moved into the [[negative flag]], and the second most significant bit of that data is moved into the [[overflow flag]].  BIT is often used right before a conditional branch instruction like [[BVC]] or [[BVS]].&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BIT #const&lt;br /&gt;
BIT addr&lt;br /&gt;
BIT dp&lt;br /&gt;
BIT addr, X&lt;br /&gt;
BIT dp, X&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* BIT takes an extra cycle when the accumulator is 16 bits wide, in all [[addressing modes]]&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes 24 and 34), BIT takes an extra cycle when the low byte of the [[direct page register]] is nonzero&lt;br /&gt;
* In [[Absolute Indexed, X Addressing]] only, BIT takes an extra cycle when adding the index crosses a [[page]] boundary&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[AND]]&lt;br /&gt;
* [[BPL]]&lt;br /&gt;
* [[BNE]]&lt;br /&gt;
* [[BCC]]&lt;br /&gt;
* [[BCS]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/431 page 431] on BIT&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n131 page 121] on BIT&lt;br /&gt;
* 4.2.2.1 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n62 page 47] on BIT&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n262 page 249] on BIT&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n94 page 3-45] on BIT&lt;br /&gt;
* snes9x implementation of BIT: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L265&lt;br /&gt;
* undisbeliever on BIT: https://undisbeliever.net/snesdev/65816-opcodes.html#bit-test-memory-bits-against-accumulator&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#BIT&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.2.2&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group Three Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=SBC&amp;diff=21198</id>
		<title>SBC</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=SBC&amp;diff=21198"/>
		<updated>2026-05-15T02:53:35Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ page 533 does not have this superscript&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|E9&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|ED&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Addressing|Absolute Long]]&lt;br /&gt;
|EF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page|Direct Page]]&lt;br /&gt;
|E5&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Addressing|Direct Page Indirect]]&lt;br /&gt;
|F2&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long]]&lt;br /&gt;
|E7&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|FD&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Indexed by X]]&lt;br /&gt;
|FF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by Y]]&lt;br /&gt;
|F9&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|F5&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed Indirect by X]]&lt;br /&gt;
|E1&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Indexed by Y]]&lt;br /&gt;
|F1&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long Indexed by Y]]&lt;br /&gt;
|F7&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative]]&lt;br /&gt;
|E3&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative Indirect Indexed by Y]]&lt;br /&gt;
|F3&lt;br /&gt;
|2 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[N Flag|N]]&lt;br /&gt;
|[[V Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[D Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Z Flag|Z]]&lt;br /&gt;
|[[C Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|V&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|C&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SBC&#039;&#039;&#039; (Subtract with Carry/Borrow) is the main 65x subtraction instruction.  The [[accumulator]] serves as both the minuend and where the difference is stored.  The operand serves as the subtrahend.  For example, SBC #6 does &amp;quot;a minus 6&amp;quot; but there is this caveat about the carry flag:&lt;br /&gt;
&lt;br /&gt;
If the [[carry flag]] (aka borrow flag) is clear, one more is subtracted.  As there is no subtract-without-carry instruction, [[SEC]] should be run beforehand or the carry flag should otherwise be ensured to be set, otherwise the difference may be one greater than expected.&lt;br /&gt;
&lt;br /&gt;
The size of the accumulator determines whether this is an 8 or 16 bit operation. If 16-bit and not using [[immediate addressing]], the low-order byte is located at the effective address and the high-order byte at the effective address plus one. &lt;br /&gt;
&lt;br /&gt;
If the difference is negative, the carry flag will be cleared, otherwise it will be set.  If the [[decimal flag]] is set, then [[binary coded decimal]] subtraction is performed, otherwise binary subtraction.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SBC #const&lt;br /&gt;
SBC addr&lt;br /&gt;
SBC long&lt;br /&gt;
SBC dp&lt;br /&gt;
SBC (dp)&lt;br /&gt;
SBC [dp]&lt;br /&gt;
SBC addr, X&lt;br /&gt;
SBC long, X&lt;br /&gt;
SBC addr, Y&lt;br /&gt;
SBC dp, X&lt;br /&gt;
SBC (dp, X)&lt;br /&gt;
SBC (dp), Y&lt;br /&gt;
SBC [dp], Y&lt;br /&gt;
SBC sr, S&lt;br /&gt;
SBC (sr, S), Y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you only need to subtract one, consider [[DEC]] instead.&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
SBC takes an extra cycle for each of the following:&lt;br /&gt;
* if the accumulator is 16 bits wide, in all addressing modes&lt;br /&gt;
* when utilizing the [[direct register]] (opcodes E5, F2, E7, F5, E1, F1, and F7), if the low byte of the direct register is nonzero&lt;br /&gt;
* In both [[Absolute Indexed]] and [[Direct Page Indirect Indexed by Y]] addressing modes if adding an index crosses a [[page]] boundary&lt;br /&gt;
&lt;br /&gt;
Unlike the 65c02, the 65c816 does not have a cycle penalty when subtracting in decimal mode.&lt;br /&gt;
&lt;br /&gt;
In [[Eyes &amp;amp; Lichty]] on page 498, opcode F5 has a &amp;quot;0&amp;quot; superscript typo on the # of cycles column.  On page 533 opcode F5 does not have this superscript.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[ADC]]&lt;br /&gt;
* [[SBC (SPC700)]]&lt;br /&gt;
* [[SUB (Super FX)]]&lt;br /&gt;
* [[DEX]]&lt;br /&gt;
* [[DEY]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/497 page 497] on SBC&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n189 page 179] on SBC&lt;br /&gt;
* 2.2.2 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n29 page 14] on SBC&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n284 page 271] on SBC&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n140 page 3-91] on SBC&lt;br /&gt;
* snes9x implementation of SBC: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L1133&lt;br /&gt;
* undisbeliever on SBC: https://undisbeliever.net/snesdev/65816-opcodes.html#sbc-subtract-with-borrow-from-accumulator&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#SBC&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.1.1&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group One Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=AND&amp;diff=21197</id>
		<title>AND</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=AND&amp;diff=21197"/>
		<updated>2026-05-15T02:50:57Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ page 528 does not have this superscript&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|29&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|2D&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long]]&lt;br /&gt;
|2F&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|25&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect]]&lt;br /&gt;
|32&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long]]&lt;br /&gt;
|27&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|3D&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Indexed by X]]&lt;br /&gt;
|3F&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by Y]]&lt;br /&gt;
|39&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|35&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed Indirect by X]]&lt;br /&gt;
|21&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Indexed by Y]]&lt;br /&gt;
|31&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long Indexed by Y]]&lt;br /&gt;
|37&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative]]&lt;br /&gt;
|23&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative Indirect Indexed by Y]]&lt;br /&gt;
|33&lt;br /&gt;
|2 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;AND&#039;&#039;&#039; is a 65x instruction that performs a logical AND.  The conjunction is stored in the [[accumulator]].  The size of the accumulator determines how much data is ANDed: if 16-bit and not using [[immediate addressing]], the low-order byte is located at the effective address and the high-order byte at the effective address plus one.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
AND #const&lt;br /&gt;
AND addr&lt;br /&gt;
AND long&lt;br /&gt;
AND dp&lt;br /&gt;
AND (dp)&lt;br /&gt;
AND [dp]&lt;br /&gt;
AND addr, X&lt;br /&gt;
AND long, X&lt;br /&gt;
AND addr, Y&lt;br /&gt;
AND dp, X&lt;br /&gt;
AND (dp, X)&lt;br /&gt;
AND (dp), Y&lt;br /&gt;
AND [dp], Y&lt;br /&gt;
AND sr, S&lt;br /&gt;
AND (sr, S), Y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* In all [[addressing modes]], AND takes one extra cycle when the accumulator is 16 bits wide.&lt;br /&gt;
* In [[direct page addressing]] modes only (opcodes 25, 32, 27, 35, 21, 31, 37), AND takes an extra cycle if the low byte of the [[direct page register]] is nonzero.&lt;br /&gt;
* In both [[Absolute Indexed]] addressing modes and [[Direct Page Indirect Indexed by Y]] admodes, AND takes an extra cycle if adding the index crosses a page boundary.&lt;br /&gt;
&lt;br /&gt;
[[Eyes &amp;amp; Lichty]] has a typo on page 426, referring to cycle penalty #0 in a superscript for opcode 37.  On page 528 opcode 37 does not have this superscript.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[ORA]]&lt;br /&gt;
* [[EOR]]&lt;br /&gt;
* [[BIT]]&lt;br /&gt;
* [[AND (SPC700)]]&lt;br /&gt;
* [[AND (Super FX)]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/425 page 425] on AND&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n126 page 116] on AND&lt;br /&gt;
* 2.2.4.1 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n35 page 20] on AND&lt;br /&gt;
* [https://archive.org/details/mos_microcomputers_programming_manual/page/n204 B-3], lbid.&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n259 page 246] on AND&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n89 page 3-40] on AND&lt;br /&gt;
* undisbeliever on AND: https://undisbeliever.net/snesdev/65816-opcodes.html#and-and-accumulator-with-memory&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#AND&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.2.1&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group One Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=MERGE_(Super_FX)&amp;diff=21196</id>
		<title>MERGE (Super FX)</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=MERGE_(Super_FX)&amp;diff=21196"/>
		<updated>2026-05-14T21:40:45Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: added how flags are affected&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;ROM Speed&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;RAM Speed&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Cache Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Implied]] (type 1)&lt;br /&gt;
|70&lt;br /&gt;
|1 byte&lt;br /&gt;
|3 cycles&lt;br /&gt;
|3 cycles&lt;br /&gt;
|1 cycle&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[B Flag|B]]&lt;br /&gt;
|[[ALT1]]&lt;br /&gt;
|[[ALT2]]&lt;br /&gt;
|[[O/V]]&lt;br /&gt;
|[[Sign Flag|S]]&lt;br /&gt;
|[[CY]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|+&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|O/V&lt;br /&gt;
|S&lt;br /&gt;
|CY&lt;br /&gt;
|Z&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;MERGE&#039;&#039;&#039; is a [[Super FX]] instruction that merges the high bytes of two specific general registers into the [[destination register]].&lt;br /&gt;
&lt;br /&gt;
The high byte of D&amp;lt;sub&amp;gt;reg&amp;lt;/sub&amp;gt; comes from R&amp;lt;sub&amp;gt;7&amp;lt;/sub&amp;gt;.&lt;br /&gt;
The low byte of D&amp;lt;sub&amp;gt;reg&amp;lt;/sub&amp;gt; comes from R&amp;lt;sub&amp;gt;8&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The official documentation has several bits labeled &amp;quot;B&amp;quot; not &#039;D&amp;quot; below the &amp;quot;Flags affected&amp;quot; table.&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt;  The O/V  flag is set if the result of (D6, D7, D14, or D15) is 1 and cleared if 0.  The sign flag is set if the result of (D7 or D15) is 1 and cleared if 0.  The C/Y  flag is set if the result of (D5, D6, D7, D13, D14, or D15) is 1 and cleared if 0.  The zero flag is set if the result of (D4, D5, D6, D7, D12, D13, D14, or D15) is 1 and cleared if 0.&lt;br /&gt;
&lt;br /&gt;
The [[ALT0]] state is restored.&lt;br /&gt;
&lt;br /&gt;
The destination register should be specified in advance using [[WITH]] or [[TO]].  Otherwise, R&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; serves as the default.  The [[source register]] is ignored.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
MERGE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
Let:&lt;br /&gt;
 D&amp;lt;sub&amp;gt;reg&amp;lt;/sub&amp;gt; : R&amp;lt;sub&amp;gt;9&amp;lt;/sub&amp;gt;&lt;br /&gt;
 R&amp;lt;sub&amp;gt;7&amp;lt;/sub&amp;gt; = 05aah&lt;br /&gt;
 R&amp;lt;sub&amp;gt;8&amp;lt;/sub&amp;gt; = fc33h&lt;br /&gt;
After executing MERGE:&lt;br /&gt;
 R&amp;lt;sub&amp;gt;9&amp;lt;/sub&amp;gt; = 05fch&lt;br /&gt;
and the sign, overflow, carry, and zero flags are set&lt;br /&gt;
&lt;br /&gt;
[[File:gsu_merge.png]]&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[HIB]]&lt;br /&gt;
* [[LOB]]&lt;br /&gt;
* [[SEX]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* Official Nintendo documentation on MERGE: paragraph 9.56 on [https://archive.org/details/SNESDevManual/book2/page/n235 page 2-9-79 of Book II]&lt;br /&gt;
* example: [https://archive.org/details/SNESDevManual/book2/page/n236 page 2-9-80 of Book II], lbid.&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Super FX]]&lt;br /&gt;
[[Category:Byte Transfer Instructions]]&lt;br /&gt;
[[Category:One-byte Instructions]]&lt;br /&gt;
[[Category:Expects Sreg/Dreg Prearranged]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Background_Mode&amp;diff=21195</id>
		<title>Background Mode</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Background_Mode&amp;diff=21195"/>
		<updated>2026-05-14T09:13:30Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: pluralize bits&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;On the SNES hardware, the BG modes are used to specify the number of layers, the color depth of the graphics and some effect avaliable.  There are 8 different BG modes. The BG mode is stored in bits 0,1 and 2 of $2105&lt;br /&gt;
&lt;br /&gt;
* [[Mode 0]]: 4 layers, all using 2bpp graphic.&lt;br /&gt;
* [[Mode 1]]: 3 layers, two using 4bpp graphic and one using 2bpp graphic. This is one of the most commonly used video modes.&lt;br /&gt;
* [[Mode 2]]: 2 layers, both using 4bpp graphic. Each tile can be individually scrolled.&lt;br /&gt;
* [[Mode 3]]: 2 layers, one using 8bpp graphic and one using 4bpp graphic. The 8bpp layer can also directly specify colors from an 11-bit (RGB443) colorspace.&lt;br /&gt;
* [[Mode 4]]: 2 layers, one using the 8bpp graphic and one using 2bpp graphic. The 8bpp layer can directly specify colors as with Mode 3, and each tile can be individually scrolled as in Mode 2.&lt;br /&gt;
* [[Mode 5]]: 2 layers, one using 4bpp graphic and one using 2bpp graphic. In this mode, output is always 512 pixels horizontally with altered tile decoding to facilitate use of the 512-width and interlaced modes.&lt;br /&gt;
* [[Mode 6]]: 1 layer, using 4bpp graphic. Output is as in Mode 5, and individual tiles are scrolled as in Mode 2.&lt;br /&gt;
* [[Mode 7]]: 1 layer of 128x128 tiles from a set of 256, which can be interpreted as 8bpp or 7bpp (using the higher bit as a pixel priority bit) depending of bit 7 of $2133 . The layer may be rotated and scaled using matrix transformations. HDMA is often used to change the matrix parameters for each scanline to generate perspective effects, giving a pseudo-3d effect.&lt;br /&gt;
&lt;br /&gt;
=== Reference ===&lt;br /&gt;
* [https://archive.org/details/SNESDevManual/book1/page/n62 page 2-3-1 of Book I] of the official Super Nintendo development manual&lt;br /&gt;
&lt;br /&gt;
[[Category:SNES Hardware]]&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=fullsnes&amp;diff=21194</id>
		<title>fullsnes</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=fullsnes&amp;diff=21194"/>
		<updated>2026-05-14T08:37:07Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Errata */ BRK&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Fullsnes&#039;&#039;&#039; is a large hardware reference for the SNES created by [[nocash]] with several ascii art illustrations.&lt;br /&gt;
&lt;br /&gt;
=== Errata ===&lt;br /&gt;
* It may be more correct to say that the [[SPC700]] has no *hardware* interrupt sources rather than no interrupt sources whatsoever due to the existence of the [[BRK (SPC700)]] instruction.&lt;br /&gt;
* With regards to the [[break flag]], this sentence is dubious: &amp;quot;PHP opcodes always write &amp;quot;1&amp;quot; into the bit&amp;quot;&lt;br /&gt;
* The [[Color Math]] register at 2130h is missing an &amp;quot;S&amp;quot; - the full name is CGSWSEL not CGWSEL.&lt;br /&gt;
* In https://problemkaputt.de/fullsnes.htm#snesapumaincpucommunicationport, fullsnes only mentions storing the entrypoint to 2142h and does not mention whether the entrypoint is a word or byte (the other places in this section where the bracket notation omits &amp;quot;Byte&amp;quot; or &amp;quot;Word&amp;quot; it is a single byte being stored).  The Official Super Nintendo development manual is clear that the program start address for the uploaded SPC700 driver is stored to both PORT 2 and 3 (as part of step 11 on page D-2).&lt;br /&gt;
* In https://problemkaputt.de/fullsnes.htm#snescartridgecicnotes, the formula for the [[Polynomial Counter]] is missing an inversion in the second term.&lt;br /&gt;
* In https://problemkaputt.de/fullsnes.htm#snespputimersandstatus, the [[Interlace Odd/Even Flag]] should use the term &amp;quot;field&amp;quot; instead of &amp;quot;frame&amp;quot; as an interlaced field is half of a frame&lt;br /&gt;
* In https://problemkaputt.de/fullsnes.htm#snesapuspc700ioports, it could be clearer that bits 0-3 of TnOUT are reset to 0 automatically by hardware after reading - it is not the programmer&#039;s responsibility to zero them after reading. &amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt;&lt;br /&gt;
* In https://problemkaputt.de/fullsnes.htm#snesapudspvolumeregisters, MVOL should stand for &amp;quot;main volume,&amp;quot; not &amp;quot;master volume&amp;quot; because MVOL does not control the echo volume, and &amp;quot;Main Volume&amp;quot; is how the official docs expand &amp;quot;MVOL.&amp;quot; &amp;lt;sup&amp;gt;[2]&amp;lt;/sup&amp;gt;&lt;br /&gt;
* In https://problemkaputt.de/fullsnes.htm#snesapublockdiagram, the word &amp;quot;Reverb&amp;quot; is used (the only place this word is used in fullsnes) but should probably say &amp;quot;Echo&amp;quot; instead like the rest of the times this feature is mentioned, as they have slightly different musical meanings.&lt;br /&gt;
* In https://problemkaputt.de/fullsnes.htm#snesapudspechoregisters, &amp;quot;bit&amp;quot; should be plural in several places when describing the ESA buffer entry bytes&lt;br /&gt;
* In https://problemkaputt.de/fullsnes.htm#snescartridgeromimageinterleave, the worst case scenario can much worse than triple-interleaved or double-mis-de-interleaved - in fact ten interleavings of a normal 320Kbyte file is the identity operation, so in this particular case the worst is quintuple-interleaved.&lt;br /&gt;
* &amp;quot;Game Boy&amp;quot; is spelled several times as one word&lt;br /&gt;
* In the https://problemkaputt.de/fullsnes.htm#snesapumaincpucommunicationport notes there is a typo: &amp;quot;injumping&amp;quot;&lt;br /&gt;
* In https://problemkaputt.de/fullsnes.htm#snesapuspc700ioports under &amp;quot;SPC700 Waitstates on Internal Cycles&amp;quot; the note at the bottom has typo: &amp;quot;cylces&amp;quot;&lt;br /&gt;
* In the IPL Boot ROM Disassembly, both the zerofill and transfer loops have a typo where &amp;quot;loop&amp;quot; is spelled with one &amp;quot;o&amp;quot;&lt;br /&gt;
* The four communication ports between the [[APU]] and the [[5A22]] are prefixed CPUIO (cpu input/output) on the 5A22 side but APUI0 (apu eye zero) on the APU side&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
&lt;br /&gt;
* https://problemkaputt.de/fullsnes.htm&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
# [https://archive.org/details/SNESDevManual/book1/page/n164 Page 3-5-2 of Book I] of the official Super Nintendo development manual: &amp;quot;When CN is read, the 4-bit up counter alone is cleared through IC internal timing&amp;quot;&lt;br /&gt;
# [https://archive.org/details/SNESDevManual/book1/page/n175 page 3-7-9 of Book I] lbid&lt;br /&gt;
&lt;br /&gt;
[[Category:SNES Hardware]]&lt;br /&gt;
[[Category:Documents]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Interrupt_Handler&amp;diff=21193</id>
		<title>Interrupt Handler</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Interrupt_Handler&amp;diff=21193"/>
		<updated>2026-05-14T07:05:00Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: numbered order&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An &#039;&#039;&#039;Interrupt Handler&#039;&#039;&#039; is a subroutine which the CPU automatically runs when an interrupt occurs.&lt;br /&gt;
&lt;br /&gt;
ISR stands for &amp;quot;interrupt service routine.&amp;quot;  Interrupts are never serviced when an instruction is only partially finished running (except if you count [[MVP]]/[[MVN]] which can be interrupted once every 7 cycles), but only after the instruction completes.&lt;br /&gt;
&lt;br /&gt;
Use [[BRK]] to force a software interrupt.&lt;br /&gt;
&lt;br /&gt;
When an interrupt occurs, the following are pushed to the [[stack]] in this exact order:&lt;br /&gt;
# [[program bank register]]&lt;br /&gt;
# [[program counter]] high byte&lt;br /&gt;
# program counter low byte&lt;br /&gt;
# [[status register]]&lt;br /&gt;
&lt;br /&gt;
Return control back with [[RTI]] when on the [[65c816]] or [[RETI]] when on the [[SPC700]].&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[NMI]]&lt;br /&gt;
* [[IRQ]]&lt;br /&gt;
* [[WAI]]&lt;br /&gt;
* [[Interrupt Request]]&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Program_Counter&amp;diff=21192</id>
		<title>Program Counter</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Program_Counter&amp;diff=21192"/>
		<updated>2026-05-14T06:36:43Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: linkify abs addressing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Program Counter&#039;&#039;&#039; (PC) points to the next instruction byte to fetch.  On both the [[65c816]] and [[S-SMP]] it is 16 bits wide.  The low byte is called PCL and the high byte is called PCH.&lt;br /&gt;
&lt;br /&gt;
If incremented past FFFFh, it wraps around to zero.&amp;lt;sup&amp;gt;[E&amp;amp;L, page 34]&amp;lt;/sup&amp;gt;  It is incremented after opcode fetch.&lt;br /&gt;
&lt;br /&gt;
The 6502 had 16-bit [[absolute addressing]] but only an 8-bit adder, so in [[emulation mode]] branches that cross a page boundary incur a one cycle penalty.  65c816 native mode has no such penalty because the full 16-bit adder is used.&lt;br /&gt;
&lt;br /&gt;
Interrupts cause the program counter to be pushed to the stack (high byte first).&lt;br /&gt;
&lt;br /&gt;
The program counter alone is not enough to uniquely identify the current instruction - the [[program bank register]] holds the high byte of the full 24-bit address.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[Stack Pointer]]&lt;br /&gt;
* [[Super_FX#Program_Counter_(R15)]]&lt;br /&gt;
* [[BRA]]&lt;br /&gt;
* [[JMP]]&lt;br /&gt;
* [[RTS]]&lt;br /&gt;
* [[RTL]]&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/33 page 33]&lt;br /&gt;
* subparagraph 8.1.4 on [https://archive.org/details/SNESDevManual/book1/page/n182 page 3-8-4 of Book I] of the official Super Nintendo development manual&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#PC&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.2.1.1&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Registers]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Program_Counter&amp;diff=21191</id>
		<title>Program Counter</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Program_Counter&amp;diff=21191"/>
		<updated>2026-05-14T06:26:22Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: explain pbr&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Program Counter&#039;&#039;&#039; (PC) points to the next instruction byte to fetch.  On both the [[65c816]] and [[S-SMP]] it is 16 bits wide.  The low byte is called PCL and the high byte is called PCH.&lt;br /&gt;
&lt;br /&gt;
If incremented past FFFFh, it wraps around to zero.&amp;lt;sup&amp;gt;[E&amp;amp;L, page 34]&amp;lt;/sup&amp;gt;  It is incremented after opcode fetch.&lt;br /&gt;
&lt;br /&gt;
The 6502 had 16-bit absolute addressing but only an 8-bit adder, so in [[emulation mode]] branches that cross a page boundary incur a one cycle penalty.  65c816 native mode has no such penalty because the full 16-bit adder is used.&lt;br /&gt;
&lt;br /&gt;
Interrupts cause the program counter to be pushed to the stack (high byte first).&lt;br /&gt;
&lt;br /&gt;
The program counter alone is not enough to uniquely identify the current instruction - the [[program bank register]] holds the high byte of the full 24-bit address.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[Stack Pointer]]&lt;br /&gt;
* [[Super_FX#Program_Counter_(R15)]]&lt;br /&gt;
* [[BRA]]&lt;br /&gt;
* [[JMP]]&lt;br /&gt;
* [[RTS]]&lt;br /&gt;
* [[RTL]]&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/33 page 33]&lt;br /&gt;
* subparagraph 8.1.4 on [https://archive.org/details/SNESDevManual/book1/page/n182 page 3-8-4 of Book I] of the official Super Nintendo development manual&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#PC&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.2.1.1&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Registers]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Program_Counter&amp;diff=21190</id>
		<title>Program Counter</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Program_Counter&amp;diff=21190"/>
		<updated>2026-05-14T05:07:56Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: when incremented&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Program Counter&#039;&#039;&#039; (PC) points to the next instruction byte to fetch.  On both the [[65c816]] and [[S-SMP]] it is 16 bits wide.  The low byte is called PCL and the high byte is called PCH.&lt;br /&gt;
&lt;br /&gt;
If incremented past FFFFh, it wraps around to zero.&amp;lt;sup&amp;gt;[E&amp;amp;L, page 34]&amp;lt;/sup&amp;gt;  It is incremented after opcode fetch.&lt;br /&gt;
&lt;br /&gt;
The 6502 had 16-bit absolute addressing but only an 8-bit adder, so in [[emulation mode]] branches that cross a page boundary incur a one cycle penalty.  65c816 native mode has no such penalty because the full 16-bit adder is used.&lt;br /&gt;
&lt;br /&gt;
Interrupts cause the program counter to be pushed to the stack (high byte first).&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[Program Bank Register]]&lt;br /&gt;
* [[Stack Pointer]]&lt;br /&gt;
* [[Super_FX#Program_Counter_(R15)]]&lt;br /&gt;
* [[BRA]]&lt;br /&gt;
* [[JMP]]&lt;br /&gt;
* [[RTS]]&lt;br /&gt;
* [[RTL]]&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/33 page 33]&lt;br /&gt;
* subparagraph 8.1.4 on [https://archive.org/details/SNESDevManual/book1/page/n182 page 3-8-4 of Book I] of the official Super Nintendo development manual&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#PC&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.2.1.1&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Registers]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Pipeline&amp;diff=21189</id>
		<title>Pipeline</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Pipeline&amp;diff=21189"/>
		<updated>2026-05-14T05:05:09Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: Xetheria moved page Pipeline to Pipelining&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Pipelining]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Pipelining&amp;diff=21188</id>
		<title>Pipelining</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Pipelining&amp;diff=21188"/>
		<updated>2026-05-14T05:05:09Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: Xetheria moved page Pipeline to Pipelining&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Pipelining&#039;&#039;&#039; is a feature of 65x processors to increase throughput.&lt;br /&gt;
&lt;br /&gt;
When finishing up an [[ADC]] instruction for example, these two things are happening simultaneously:&lt;br /&gt;
* opcode fetch for the next instruction&lt;br /&gt;
* the [[internal cycle]] of putting the sum into the accumulator.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[Super_FX#Pipeline_Processing]]&lt;br /&gt;
&lt;br /&gt;
=== Reference ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/40 page 40]&lt;br /&gt;
&lt;br /&gt;
[[Category:SNES Hardware]]&lt;br /&gt;
[[Category:ASM]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Index_Register_Select&amp;diff=21187</id>
		<title>Index Register Select</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Index_Register_Select&amp;diff=21187"/>
		<updated>2026-05-14T03:55:28Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: RTI pops it off the stack&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Index Register Select&#039;&#039;&#039; (X) is a flag in the [[processor status register]] (bit 4) of the [[65c816]].  It indicates how wide the [[index register]]s are:&lt;br /&gt;
&lt;br /&gt;
* When clear, both index registers are 16 bits wide.  It can only be clear in [[native mode]].&lt;br /&gt;
* When set or in [[emulation mode]], both index registers are 8 bits wide and the high bytes are forced to zero.&lt;br /&gt;
&lt;br /&gt;
It is not possible to control the width of the two index registers individually.&lt;br /&gt;
&lt;br /&gt;
It can be affected by:&lt;br /&gt;
&lt;br /&gt;
* [[REP]] (clears it if bit 4 of operand is set)&lt;br /&gt;
* [[SEP]] (sets it if bit 4 of operand is set)&lt;br /&gt;
* [[PLP]] (pops it off the [[stack]])&lt;br /&gt;
* [[RTI]] (pops it off the stack)&lt;br /&gt;
&lt;br /&gt;
It affects the behavior of (possibly incomplete list):&lt;br /&gt;
* [[LDX]]&lt;br /&gt;
* [[LDY]]&lt;br /&gt;
* [[STX]]&lt;br /&gt;
* [[STY]]&lt;br /&gt;
* [[CPX]]&lt;br /&gt;
* [[CPY]]&lt;br /&gt;
* [[PHX]]&lt;br /&gt;
* [[PHY]]&lt;br /&gt;
* [[PLX]]&lt;br /&gt;
* [[PLY]]&lt;br /&gt;
* [[INX]]&lt;br /&gt;
* [[INY]]&lt;br /&gt;
* [[DEX]]&lt;br /&gt;
* [[DEY]]&lt;br /&gt;
* [[TXY]]&lt;br /&gt;
* [[TYX]]&lt;br /&gt;
* [[TXS]]&lt;br /&gt;
* [[TSX]]&lt;br /&gt;
&lt;br /&gt;
In [[emulation mode]], the x flag becomes the [[break flag]].&lt;br /&gt;
&lt;br /&gt;
There are no BXS or BXC instructions that examine this flag.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[Memory/Accumulator Select]]&lt;br /&gt;
* [[X Index Register]]&lt;br /&gt;
* [[Y Index Register]]&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/422 page 422], Table 18.2. 65x Flags.&lt;br /&gt;
* 65c816 datasheet paragraph 2.7 &amp;quot;Index (X and Y)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Flags]]&lt;br /&gt;
[[Category:65c816 additions]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Index_Register_Select&amp;diff=21186</id>
		<title>Index Register Select</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Index_Register_Select&amp;diff=21186"/>
		<updated>2026-05-14T03:02:07Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* References */ paragraph name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Index Register Select&#039;&#039;&#039; (X) is a flag in the [[processor status register]] (bit 4) of the [[65c816]].  It indicates how wide the [[index register]]s are:&lt;br /&gt;
&lt;br /&gt;
* When clear, both index registers are 16 bits wide.  It can only be clear in [[native mode]].&lt;br /&gt;
* When set or in [[emulation mode]], both index registers are 8 bits wide and the high bytes are forced to zero.&lt;br /&gt;
&lt;br /&gt;
It is not possible to control the width of the two index registers individually.&lt;br /&gt;
&lt;br /&gt;
It can be affected by:&lt;br /&gt;
&lt;br /&gt;
* [[REP]] (clears it if bit 4 of operand is set)&lt;br /&gt;
* [[SEP]] (sets it if bit 4 of operand is set)&lt;br /&gt;
* [[PLP]] (pops it off the [[stack]])&lt;br /&gt;
* [[RTI]]&lt;br /&gt;
&lt;br /&gt;
It affects the behavior of (possibly incomplete list):&lt;br /&gt;
* [[LDX]]&lt;br /&gt;
* [[LDY]]&lt;br /&gt;
* [[STX]]&lt;br /&gt;
* [[STY]]&lt;br /&gt;
* [[CPX]]&lt;br /&gt;
* [[CPY]]&lt;br /&gt;
* [[PHX]]&lt;br /&gt;
* [[PHY]]&lt;br /&gt;
* [[PLX]]&lt;br /&gt;
* [[PLY]]&lt;br /&gt;
* [[INX]]&lt;br /&gt;
* [[INY]]&lt;br /&gt;
* [[DEX]]&lt;br /&gt;
* [[DEY]]&lt;br /&gt;
* [[TXY]]&lt;br /&gt;
* [[TYX]]&lt;br /&gt;
* [[TXS]]&lt;br /&gt;
* [[TSX]]&lt;br /&gt;
&lt;br /&gt;
In [[emulation mode]], the x flag becomes the [[break flag]].&lt;br /&gt;
&lt;br /&gt;
There are no BXS or BXC instructions that examine this flag.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[Memory/Accumulator Select]]&lt;br /&gt;
* [[X Index Register]]&lt;br /&gt;
* [[Y Index Register]]&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/422 page 422], Table 18.2. 65x Flags.&lt;br /&gt;
* 65c816 datasheet paragraph 2.7 &amp;quot;Index (X and Y)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Flags]]&lt;br /&gt;
[[Category:65c816 additions]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=BRA_(Super_FX)&amp;diff=21185</id>
		<title>BRA (Super FX)</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=BRA_(Super_FX)&amp;diff=21185"/>
		<updated>2026-05-13T21:53:43Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: all flags ignored&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;ROM Speed&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;RAM Speed&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Cache Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Program Counter Relative]]&lt;br /&gt;
|05??&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles&lt;br /&gt;
|6 cycles&lt;br /&gt;
|2 cycles&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[B Flag|B]]&lt;br /&gt;
|[[ALT1]]&lt;br /&gt;
|[[ALT2]]&lt;br /&gt;
|[[O/V]]&lt;br /&gt;
|[[Sign Flag|S]]&lt;br /&gt;
|[[CY]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|+&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BRA&#039;&#039;&#039; (Branch) is a [[Super FX]] instruction that performs an unconditional jump.  A relative offset of -128 to 127 bytes from the address following the BRA instruction is added into R&amp;lt;sub&amp;gt;15&amp;lt;/sub&amp;gt; (the program counter).&lt;br /&gt;
&lt;br /&gt;
No flags are affected.  All flags are ignored.&lt;br /&gt;
&lt;br /&gt;
The instruction after BRA is already in the pipeline and will be run before the instruction at the branch destination.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BRA e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
This instruction jumps the program backward in an infinite loop:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 BRA $0h&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[JMP (Super FX)]]&lt;br /&gt;
* [[LJMP (Super FX)]]&lt;br /&gt;
* [[BRA]]&lt;br /&gt;
* [[BRA (SPC700)]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* Official Nintendo documentation on BRA: 9.24 on [https://archive.org/details/SNESDevManual/book2/page/n188 page 2-9-32 of Book II]&lt;br /&gt;
* example: [https://archive.org/details/SNESDevManual/book2/page/n189 page 2-9-33 of Book II], lbid.&lt;br /&gt;
&lt;br /&gt;
[[Category:Super FX]]&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Two-byte Instructions]]&lt;br /&gt;
[[Category:Instructions with Delay Slots]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=BRA_(Super_FX)&amp;diff=21184</id>
		<title>BRA (Super FX)</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=BRA_(Super_FX)&amp;diff=21184"/>
		<updated>2026-05-13T21:11:39Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* See Also */ (BRA spc700)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;ROM Speed&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;RAM Speed&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Cache Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Program Counter Relative]]&lt;br /&gt;
|05??&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles&lt;br /&gt;
|6 cycles&lt;br /&gt;
|2 cycles&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[B Flag|B]]&lt;br /&gt;
|[[ALT1]]&lt;br /&gt;
|[[ALT2]]&lt;br /&gt;
|[[O/V]]&lt;br /&gt;
|[[Sign Flag|S]]&lt;br /&gt;
|[[CY]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|+&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BRA&#039;&#039;&#039; (Branch) is a [[Super FX]] instruction that performs an unconditional jump.  A relative offset of -128 to 127 bytes from the address following the BRA instruction is added into R&amp;lt;sub&amp;gt;15&amp;lt;/sub&amp;gt; (the program counter).&lt;br /&gt;
&lt;br /&gt;
No flags are affected.&lt;br /&gt;
&lt;br /&gt;
The instruction after BRA is already in the pipeline and will be run before the instruction at the branch destination.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BRA e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
This instruction jumps the program backward in an infinite loop:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 BRA $0h&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[JMP (Super FX)]]&lt;br /&gt;
* [[LJMP (Super FX)]]&lt;br /&gt;
* [[BRA]]&lt;br /&gt;
* [[BRA (SPC700)]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* Official Nintendo documentation on BRA: 9.24 on [https://archive.org/details/SNESDevManual/book2/page/n188 page 2-9-32 of Book II]&lt;br /&gt;
* example: [https://archive.org/details/SNESDevManual/book2/page/n189 page 2-9-33 of Book II], lbid.&lt;br /&gt;
&lt;br /&gt;
[[Category:Super FX]]&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Two-byte Instructions]]&lt;br /&gt;
[[Category:Instructions with Delay Slots]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Timing_Control_Unit&amp;diff=21183</id>
		<title>Timing Control Unit</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Timing_Control_Unit&amp;diff=21183"/>
		<updated>2026-05-13T21:10:30Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* List of instructions without cycle penalties: */ BRA+JMP&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Timing Control Unit&#039;&#039;&#039; (TCU) is part of the [[65c816]].  It contains a counter that is reset at each instruction fetch and advances during each [[machine cycle]].  Together with the [[instruction register]], it helps the processor perform register transfers.&lt;br /&gt;
&lt;br /&gt;
==== List of instructions with cycle penalties: ====&lt;br /&gt;
&lt;br /&gt;
* [[ADC]]&lt;br /&gt;
* [[AND]]&lt;br /&gt;
* [[ASL]]&lt;br /&gt;
* [[BCC]]&lt;br /&gt;
* [[BCS]]&lt;br /&gt;
* [[BEQ]]&lt;br /&gt;
* [[BIT]]&lt;br /&gt;
* [[BMI]]&lt;br /&gt;
* [[BNE]]&lt;br /&gt;
* [[BPL]]&lt;br /&gt;
* [[BRA]]&lt;br /&gt;
* [[BRK]]&lt;br /&gt;
* [[BVC]]&lt;br /&gt;
* [[BVS]]&lt;br /&gt;
* [[CMP]]&lt;br /&gt;
* [[COP]]&lt;br /&gt;
* [[CPX]]&lt;br /&gt;
* [[CPY]]&lt;br /&gt;
* [[DEC]]&lt;br /&gt;
* [[EOR]]&lt;br /&gt;
* [[INC]]&lt;br /&gt;
* [[LDA]]&lt;br /&gt;
* [[LDX]]&lt;br /&gt;
* [[LDY]]&lt;br /&gt;
* [[LSR]]&lt;br /&gt;
* [[ORA]]&lt;br /&gt;
* [[PEI]]&lt;br /&gt;
* [[PHA]]&lt;br /&gt;
* [[PHX]]&lt;br /&gt;
* [[PHY]]&lt;br /&gt;
* [[PLA]]&lt;br /&gt;
* [[PLX]]&lt;br /&gt;
* [[PLY]]&lt;br /&gt;
* [[ROL]]&lt;br /&gt;
* [[ROR]]&lt;br /&gt;
* [[RTI]]&lt;br /&gt;
* [[SBC]]&lt;br /&gt;
* [[STA]]&lt;br /&gt;
* [[STX]]&lt;br /&gt;
* [[STY]]&lt;br /&gt;
* [[STZ]]&lt;br /&gt;
* [[TRB]]&lt;br /&gt;
* [[TSB]]&lt;br /&gt;
* and most [[SPC700]] branching commands&lt;br /&gt;
&lt;br /&gt;
==== List of instructions without cycle penalties: ====&lt;br /&gt;
&lt;br /&gt;
* [[BRL]]&lt;br /&gt;
* [[CLC]]&lt;br /&gt;
* [[CLD]]&lt;br /&gt;
* [[CLI]]&lt;br /&gt;
* [[CLV]]&lt;br /&gt;
* [[DEX]]&lt;br /&gt;
* [[DEY]]&lt;br /&gt;
* [[INX]]&lt;br /&gt;
* [[INY]]&lt;br /&gt;
* [[JMP]] / JML&lt;br /&gt;
* [[JSL]]&lt;br /&gt;
* [[JSR]]&lt;br /&gt;
* [[MVN]]&lt;br /&gt;
* [[MVP]]&lt;br /&gt;
* [[NOP]]&lt;br /&gt;
* [[PEA]]&lt;br /&gt;
* [[PER]]&lt;br /&gt;
* [[PHB]]&lt;br /&gt;
* [[PHD]]&lt;br /&gt;
* [[PHK]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[PLB]]&lt;br /&gt;
* [[PLD]]&lt;br /&gt;
* [[PLP]]&lt;br /&gt;
* [[REP]]&lt;br /&gt;
* [[RTL]]&lt;br /&gt;
* [[RTS]]&lt;br /&gt;
* [[SEC]]&lt;br /&gt;
* [[SED]]&lt;br /&gt;
* [[SEI]]&lt;br /&gt;
* [[SEP]]&lt;br /&gt;
* [[STP]]&lt;br /&gt;
* [[TAX]]&lt;br /&gt;
* [[TAY]]&lt;br /&gt;
* [[TCD]]&lt;br /&gt;
* [[TCS]]&lt;br /&gt;
* [[TDC]]&lt;br /&gt;
* [[TSC]]&lt;br /&gt;
* [[TSX]]&lt;br /&gt;
* [[TXA]]&lt;br /&gt;
* [[TXS]]&lt;br /&gt;
* [[TXY]]&lt;br /&gt;
* [[TYA]]&lt;br /&gt;
* [[TYX]]&lt;br /&gt;
* [[WAI]]&lt;br /&gt;
* [[WDM]]&lt;br /&gt;
* [[XBA]]&lt;br /&gt;
* [[XCE]]&lt;br /&gt;
* All non-branching [[SPC700]] instructions&lt;br /&gt;
* [[BRA (SPC700)]]&lt;br /&gt;
* [[JMP (SPC700)]]&lt;br /&gt;
&lt;br /&gt;
=== Reference ===&lt;br /&gt;
* section 2.2 of 65c816 datasheet: https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf&lt;br /&gt;
&lt;br /&gt;
[[Category:SNES Hardware]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Timing]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=BRA&amp;diff=21182</id>
		<title>BRA</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=BRA&amp;diff=21182"/>
		<updated>2026-05-13T21:08:52Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* See Also */ spc700&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Program Counter Relative]]&lt;br /&gt;
|80&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BRA&#039;&#039;&#039; (BRanch Always) is a [[65c816]] instruction that performs an unconditional jump.  The signed displacement ranges from -128 to 127.  The displacement is sign-extended to 16 bits and added to the [[program counter]].  The displacement is measured from the instruction following BRA.&lt;br /&gt;
&lt;br /&gt;
BRA is relocatable.  No flags are affected.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BRA nearlabel&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BRA has the same timing as other branches, it just has no &amp;quot;branch not taken&amp;quot; case.&lt;br /&gt;
&lt;br /&gt;
===== Cycle Penalty =====&lt;br /&gt;
* BRA takes one additional cycle if the branch crosses a page boundary in [[emulation mode]].&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[JMP]]&lt;br /&gt;
* [[BRA (Super FX)]]&lt;br /&gt;
* [[BRA (SPC700)]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/435 page 435] on BRA&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n135 page 125] on BRA&lt;br /&gt;
* snes9x implementation of BRA: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L1390&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.2.1.1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:65c02 additions]]&lt;br /&gt;
[[Category:Unconditional Branches]]&lt;br /&gt;
[[Category:Two-byte Instructions]]&lt;br /&gt;
[[Category:Relocatable Instructions]]&lt;br /&gt;
[[Category:Single Admode Mnemonics]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Timing_Control_Unit&amp;diff=21181</id>
		<title>Timing Control Unit</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Timing_Control_Unit&amp;diff=21181"/>
		<updated>2026-05-13T16:34:46Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* List of instructions without cycle penalties: */ spc700&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Timing Control Unit&#039;&#039;&#039; (TCU) is part of the [[65c816]].  It contains a counter that is reset at each instruction fetch and advances during each [[machine cycle]].  Together with the [[instruction register]], it helps the processor perform register transfers.&lt;br /&gt;
&lt;br /&gt;
==== List of instructions with cycle penalties: ====&lt;br /&gt;
&lt;br /&gt;
* [[ADC]]&lt;br /&gt;
* [[AND]]&lt;br /&gt;
* [[ASL]]&lt;br /&gt;
* [[BCC]]&lt;br /&gt;
* [[BCS]]&lt;br /&gt;
* [[BEQ]]&lt;br /&gt;
* [[BIT]]&lt;br /&gt;
* [[BMI]]&lt;br /&gt;
* [[BNE]]&lt;br /&gt;
* [[BPL]]&lt;br /&gt;
* [[BRA]]&lt;br /&gt;
* [[BRK]]&lt;br /&gt;
* [[BVC]]&lt;br /&gt;
* [[BVS]]&lt;br /&gt;
* [[CMP]]&lt;br /&gt;
* [[COP]]&lt;br /&gt;
* [[CPX]]&lt;br /&gt;
* [[CPY]]&lt;br /&gt;
* [[DEC]]&lt;br /&gt;
* [[EOR]]&lt;br /&gt;
* [[INC]]&lt;br /&gt;
* [[LDA]]&lt;br /&gt;
* [[LDX]]&lt;br /&gt;
* [[LDY]]&lt;br /&gt;
* [[LSR]]&lt;br /&gt;
* [[ORA]]&lt;br /&gt;
* [[PEI]]&lt;br /&gt;
* [[PHA]]&lt;br /&gt;
* [[PHX]]&lt;br /&gt;
* [[PHY]]&lt;br /&gt;
* [[PLA]]&lt;br /&gt;
* [[PLX]]&lt;br /&gt;
* [[PLY]]&lt;br /&gt;
* [[ROL]]&lt;br /&gt;
* [[ROR]]&lt;br /&gt;
* [[RTI]]&lt;br /&gt;
* [[SBC]]&lt;br /&gt;
* [[STA]]&lt;br /&gt;
* [[STX]]&lt;br /&gt;
* [[STY]]&lt;br /&gt;
* [[STZ]]&lt;br /&gt;
* [[TRB]]&lt;br /&gt;
* [[TSB]]&lt;br /&gt;
* and most [[SPC700]] branching commands&lt;br /&gt;
&lt;br /&gt;
==== List of instructions without cycle penalties: ====&lt;br /&gt;
&lt;br /&gt;
* [[BRL]]&lt;br /&gt;
* [[CLC]]&lt;br /&gt;
* [[CLD]]&lt;br /&gt;
* [[CLI]]&lt;br /&gt;
* [[CLV]]&lt;br /&gt;
* [[DEX]]&lt;br /&gt;
* [[DEY]]&lt;br /&gt;
* [[INX]]&lt;br /&gt;
* [[INY]]&lt;br /&gt;
* [[JMP]] / JML&lt;br /&gt;
* [[JSL]]&lt;br /&gt;
* [[JSR]]&lt;br /&gt;
* [[MVN]]&lt;br /&gt;
* [[MVP]]&lt;br /&gt;
* [[NOP]]&lt;br /&gt;
* [[PEA]]&lt;br /&gt;
* [[PER]]&lt;br /&gt;
* [[PHB]]&lt;br /&gt;
* [[PHD]]&lt;br /&gt;
* [[PHK]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[PLB]]&lt;br /&gt;
* [[PLD]]&lt;br /&gt;
* [[PLP]]&lt;br /&gt;
* [[REP]]&lt;br /&gt;
* [[RTL]]&lt;br /&gt;
* [[RTS]]&lt;br /&gt;
* [[SEC]]&lt;br /&gt;
* [[SED]]&lt;br /&gt;
* [[SEI]]&lt;br /&gt;
* [[SEP]]&lt;br /&gt;
* [[STP]]&lt;br /&gt;
* [[TAX]]&lt;br /&gt;
* [[TAY]]&lt;br /&gt;
* [[TCD]]&lt;br /&gt;
* [[TCS]]&lt;br /&gt;
* [[TDC]]&lt;br /&gt;
* [[TSC]]&lt;br /&gt;
* [[TSX]]&lt;br /&gt;
* [[TXA]]&lt;br /&gt;
* [[TXS]]&lt;br /&gt;
* [[TXY]]&lt;br /&gt;
* [[TYA]]&lt;br /&gt;
* [[TYX]]&lt;br /&gt;
* [[WAI]]&lt;br /&gt;
* [[WDM]]&lt;br /&gt;
* [[XBA]]&lt;br /&gt;
* [[XCE]]&lt;br /&gt;
* All non-branching [[SPC700]] instructions&lt;br /&gt;
&lt;br /&gt;
=== Reference ===&lt;br /&gt;
* section 2.2 of 65c816 datasheet: https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf&lt;br /&gt;
&lt;br /&gt;
[[Category:SNES Hardware]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Timing]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Timing_Control_Unit&amp;diff=21180</id>
		<title>Timing Control Unit</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Timing_Control_Unit&amp;diff=21180"/>
		<updated>2026-05-13T08:01:34Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* List of instructions with cycle penalties: */ spc700&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Timing Control Unit&#039;&#039;&#039; (TCU) is part of the [[65c816]].  It contains a counter that is reset at each instruction fetch and advances during each [[machine cycle]].  Together with the [[instruction register]], it helps the processor perform register transfers.&lt;br /&gt;
&lt;br /&gt;
==== List of instructions with cycle penalties: ====&lt;br /&gt;
&lt;br /&gt;
* [[ADC]]&lt;br /&gt;
* [[AND]]&lt;br /&gt;
* [[ASL]]&lt;br /&gt;
* [[BCC]]&lt;br /&gt;
* [[BCS]]&lt;br /&gt;
* [[BEQ]]&lt;br /&gt;
* [[BIT]]&lt;br /&gt;
* [[BMI]]&lt;br /&gt;
* [[BNE]]&lt;br /&gt;
* [[BPL]]&lt;br /&gt;
* [[BRA]]&lt;br /&gt;
* [[BRK]]&lt;br /&gt;
* [[BVC]]&lt;br /&gt;
* [[BVS]]&lt;br /&gt;
* [[CMP]]&lt;br /&gt;
* [[COP]]&lt;br /&gt;
* [[CPX]]&lt;br /&gt;
* [[CPY]]&lt;br /&gt;
* [[DEC]]&lt;br /&gt;
* [[EOR]]&lt;br /&gt;
* [[INC]]&lt;br /&gt;
* [[LDA]]&lt;br /&gt;
* [[LDX]]&lt;br /&gt;
* [[LDY]]&lt;br /&gt;
* [[LSR]]&lt;br /&gt;
* [[ORA]]&lt;br /&gt;
* [[PEI]]&lt;br /&gt;
* [[PHA]]&lt;br /&gt;
* [[PHX]]&lt;br /&gt;
* [[PHY]]&lt;br /&gt;
* [[PLA]]&lt;br /&gt;
* [[PLX]]&lt;br /&gt;
* [[PLY]]&lt;br /&gt;
* [[ROL]]&lt;br /&gt;
* [[ROR]]&lt;br /&gt;
* [[RTI]]&lt;br /&gt;
* [[SBC]]&lt;br /&gt;
* [[STA]]&lt;br /&gt;
* [[STX]]&lt;br /&gt;
* [[STY]]&lt;br /&gt;
* [[STZ]]&lt;br /&gt;
* [[TRB]]&lt;br /&gt;
* [[TSB]]&lt;br /&gt;
* and most [[SPC700]] branching commands&lt;br /&gt;
&lt;br /&gt;
==== List of instructions without cycle penalties: ====&lt;br /&gt;
&lt;br /&gt;
* [[BRL]]&lt;br /&gt;
* [[CLC]]&lt;br /&gt;
* [[CLD]]&lt;br /&gt;
* [[CLI]]&lt;br /&gt;
* [[CLV]]&lt;br /&gt;
* [[DEX]]&lt;br /&gt;
* [[DEY]]&lt;br /&gt;
* [[INX]]&lt;br /&gt;
* [[INY]]&lt;br /&gt;
* [[JMP]] / JML&lt;br /&gt;
* [[JSL]]&lt;br /&gt;
* [[JSR]]&lt;br /&gt;
* [[MVN]]&lt;br /&gt;
* [[MVP]]&lt;br /&gt;
* [[NOP]]&lt;br /&gt;
* [[PEA]]&lt;br /&gt;
* [[PER]]&lt;br /&gt;
* [[PHB]]&lt;br /&gt;
* [[PHD]]&lt;br /&gt;
* [[PHK]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[PLB]]&lt;br /&gt;
* [[PLD]]&lt;br /&gt;
* [[PLP]]&lt;br /&gt;
* [[REP]]&lt;br /&gt;
* [[RTL]]&lt;br /&gt;
* [[RTS]]&lt;br /&gt;
* [[SEC]]&lt;br /&gt;
* [[SED]]&lt;br /&gt;
* [[SEI]]&lt;br /&gt;
* [[SEP]]&lt;br /&gt;
* [[STP]]&lt;br /&gt;
* [[TAX]]&lt;br /&gt;
* [[TAY]]&lt;br /&gt;
* [[TCD]]&lt;br /&gt;
* [[TCS]]&lt;br /&gt;
* [[TDC]]&lt;br /&gt;
* [[TSC]]&lt;br /&gt;
* [[TSX]]&lt;br /&gt;
* [[TXA]]&lt;br /&gt;
* [[TXS]]&lt;br /&gt;
* [[TXY]]&lt;br /&gt;
* [[TYA]]&lt;br /&gt;
* [[TYX]]&lt;br /&gt;
* [[WAI]]&lt;br /&gt;
* [[WDM]]&lt;br /&gt;
* [[XBA]]&lt;br /&gt;
* [[XCE]]&lt;br /&gt;
&lt;br /&gt;
=== Reference ===&lt;br /&gt;
* section 2.2 of 65c816 datasheet: https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf&lt;br /&gt;
&lt;br /&gt;
[[Category:SNES Hardware]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Timing]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Two-Phase_Access&amp;diff=21179</id>
		<title>Two-Phase Access</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Two-Phase_Access&amp;diff=21179"/>
		<updated>2026-05-13T07:57:48Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: SA-1 category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Two-Phase Access&#039;&#039;&#039; is when both the [[SA-1]] and [[5A22]] access the ROM.&lt;br /&gt;
&lt;br /&gt;
=== Reference ===&lt;br /&gt;
* Figure 2.2.1.3 on [https://archive.org/details/SNESDevManual/book2/page/n14 page 1-2-3 of Book II] of the official Super Nintendo development manual&lt;br /&gt;
&lt;br /&gt;
[[Category:Official Jargon]]&lt;br /&gt;
[[Category:SA-1]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Two-Phase_Access&amp;diff=21178</id>
		<title>Two-Phase Access</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Two-Phase_Access&amp;diff=21178"/>
		<updated>2026-05-13T07:56:44Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: better description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Two-Phase Access&#039;&#039;&#039; is when both the [[SA-1]] and [[5A22]] access the ROM.&lt;br /&gt;
&lt;br /&gt;
=== Reference ===&lt;br /&gt;
* Figure 2.2.1.3 on [https://archive.org/details/SNESDevManual/book2/page/n14 page 1-2-3 of Book II] of the official Super Nintendo development manual&lt;br /&gt;
&lt;br /&gt;
[[Category:Official Jargon]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Direct_Page_Register&amp;diff=21177</id>
		<title>Direct Page Register</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Direct_Page_Register&amp;diff=21177"/>
		<updated>2026-05-13T05:32:30Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: or simply Direct Register&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Direct Page Register&#039;&#039;&#039; (or simply the &#039;&#039;&#039;Direct Register&#039;&#039;&#039;) exists on the [[65c816]] and is 16 bits wide.&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt;  It holds current the location of the [[direct page]].  The low byte is called DL and the high byte DH.&lt;br /&gt;
&lt;br /&gt;
The direct page register is cleared to point to the [[zero page]] on reset.&amp;lt;sup&amp;gt;[2]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:dp.png]]&lt;br /&gt;
&lt;br /&gt;
Its value can be pushed to the [[stack]] with [[PHD]] and pulled off the stack with [[PLD]].&lt;br /&gt;
&lt;br /&gt;
Its value can be transferred to and from the full 16 bit [[accumulator]] with [[TCD]] and [[TDC]].&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
# page 5 of the official 65c816 datasheet: https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf&lt;br /&gt;
# section 2.6 on page 7, lbid.&lt;br /&gt;
# [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/53 page 53]&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Registers]]&lt;br /&gt;
[[Category:65c816 additions]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=List_of_Anomie%27s_Docs&amp;diff=21176</id>
		<title>List of Anomie&#039;s Docs</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=List_of_Anomie%27s_Docs&amp;diff=21176"/>
		<updated>2026-05-13T04:10:14Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Errata */ added at any point in the opcode&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are nine documents by anomie available on [[RHDN]]:&lt;br /&gt;
&lt;br /&gt;
* [https://www.romhacking.net/documents/193 SNES Memory Mapping]&lt;br /&gt;
* [https://www.romhacking.net/documents/196 Register]&lt;br /&gt;
* [https://www.romhacking.net/documents/199 SNES Timing]&lt;br /&gt;
* [https://www.romhacking.net/documents/197 SPC700 with boot rom disassembly]&lt;br /&gt;
* [https://www.romhacking.net/documents/198 SPC700 Cycles]&lt;br /&gt;
* [https://www.romhacking.net/documents/191 S-DSP]&lt;br /&gt;
* [https://www.romhacking.net/documents/194 SNES OpenBus and Wrapping]&lt;br /&gt;
* [https://www.romhacking.net/documents/195 SNES Port]&lt;br /&gt;
* [https://www.romhacking.net/documents/192 C4 chip]&lt;br /&gt;
&lt;br /&gt;
=== Errata ===&lt;br /&gt;
* In &#039;&#039;&#039;regs.txt&#039;&#039;&#039; under &amp;quot;BG Modes&amp;quot; we have &amp;quot;The SNES has 7 [[background modes]],&amp;quot; it should say 8.&lt;br /&gt;
* In the S-DSP doc, we have &amp;quot;Certain games do seem to depend on these exact formulas, trying to &#039;&#039;&#039;simplify&#039;&#039;&#039; will break some sound effects.&amp;quot;  But &amp;quot;approximate&amp;quot; would probably be clearer than &amp;quot;simplify,&amp;quot; as in mathematics simplifying a formula only reduces the number of symbols used to express it, which may be easier to read but otherwise leaves it equivalent.&lt;br /&gt;
* In &#039;&#039;&#039;ob-wrap.txt&#039;&#039;&#039;, the first result is that [[Program Counter]] Increment &amp;quot;Always wraps within the [[bank]], at any point in the opcode.&amp;quot;  But as opcodes are merely the first byte of an instruction, this result would probably be clearer if the last word were &amp;quot;instruction.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[List of Y0shi&#039;s Docs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:SNES Hardware]]&lt;br /&gt;
[[Category:Documents]]&lt;br /&gt;
[[Category:Lists]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=S-SMP&amp;diff=21175</id>
		<title>S-SMP</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=S-SMP&amp;diff=21175"/>
		<updated>2026-05-12T23:29:51Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: linkify zp&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;S-SMP&#039;&#039;&#039; is a Sony SPC700 series 8-bit 65x-based MPU which serves as the SNES&#039; sound chip.  It talks to the [[Ricoh 5A22]] over four ports via the [[SNES Bus]] and [[CPU Data Bus]].  It is clocked by [[CPUK]].  The minimum command execution time is 1.953 microseconds.&amp;lt;sup&amp;gt;[2]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following registers are 8-bit:&lt;br /&gt;
* [[Accumulator]]&lt;br /&gt;
* [[X Index Register]]&lt;br /&gt;
* [[Y Index Register]]&lt;br /&gt;
* [[Program Status Word]]&lt;br /&gt;
* [[Stack Pointer]]&lt;br /&gt;
&lt;br /&gt;
The following registers are 16-bit:&lt;br /&gt;
* [[Program Counter]]&lt;br /&gt;
* [[YA]] (which is virtually just the Y index reg concatenated to A)&lt;br /&gt;
&lt;br /&gt;
Instructions that try to access memory straddling past the end of [[ARAM]] (the last byte of which is at $FFFF) will wrap around and end up accessing the [[zeropage]] (which is at $0000).  Accesses that use [[direct page addressing]] will wrap within the [[direct page]].&lt;br /&gt;
&lt;br /&gt;
The stack is always located in page one (at $0100).  Memory accesses that straddle the end of the stack will wrap to the beginning of the stack.&lt;br /&gt;
&lt;br /&gt;
Operands that use [[absolute addressing]] are prefixed with an exclamation point (!).&lt;br /&gt;
&lt;br /&gt;
The S-SMP has no hardware interrupt sources, but it does have [[BRK (SPC700)|BRK]].&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[SPC700 Opcode Matrix]]&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
# [https://www.romhacking.net/documents/197 anomie&#039;s SPC700 doc]&lt;br /&gt;
# SNES Sound Source Outline on [https://archive.org/details/SNESDevManual/book1/page/n152 page 3-1-1 of Book I] of the official Super Nintendo development manual&lt;br /&gt;
# subparagraph 22.5.1 on [https://archive.org/details/SNESDevManual/book1/page/n97 page 2-22-1 of Book I], lbid.&lt;br /&gt;
&lt;br /&gt;
[[Category:SNES Hardware]]&lt;br /&gt;
[[Category:ICs with unconnected pins]]&lt;br /&gt;
[[Category:Integrated Circuits]]&lt;br /&gt;
[[Category:Audio]]&lt;br /&gt;
[[Category:SPC700]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Direct_Page_Register&amp;diff=21174</id>
		<title>Direct Page Register</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Direct_Page_Register&amp;diff=21174"/>
		<updated>2026-05-12T02:12:27Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: It -&amp;gt; its value&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Direct Page Register&#039;&#039;&#039; exists on the [[65c816]] and is 16 bits wide.&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt;  It holds current the location of the [[direct page]].  The low byte is called DL and the high byte DH.&lt;br /&gt;
&lt;br /&gt;
The direct page register is cleared to point to the [[zero page]] on reset.&amp;lt;sup&amp;gt;[2]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:dp.png]]&lt;br /&gt;
&lt;br /&gt;
Its value can be pushed to the [[stack]] with [[PHD]] and pulled off the stack with [[PLD]].&lt;br /&gt;
&lt;br /&gt;
Its value can be transferred to and from the full 16 bit [[accumulator]] with [[TCD]] and [[TDC]].&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
# page 5 of the official 65c816 datasheet: https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf&lt;br /&gt;
# section 2.6 on page 7, lbid.&lt;br /&gt;
# [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/53 page 53]&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Registers]]&lt;br /&gt;
[[Category:65c816 additions]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Direct_Page_Register&amp;diff=21173</id>
		<title>Direct Page Register</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Direct_Page_Register&amp;diff=21173"/>
		<updated>2026-05-11T23:09:08Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: DL and DH&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Direct Page Register&#039;&#039;&#039; exists on the [[65c816]] and is 16 bits wide.&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt;  It holds current the location of the [[direct page]].  The low byte is called DL and the high byte DH.&lt;br /&gt;
&lt;br /&gt;
The direct page register is cleared to point to the [[zero page]] on reset.&amp;lt;sup&amp;gt;[2]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:dp.png]]&lt;br /&gt;
&lt;br /&gt;
Its value can be pushed to the [[stack]] with [[PHD]] and pulled off the stack with [[PLD]].&lt;br /&gt;
&lt;br /&gt;
It can be transferred to and from the full 16 bit [[accumulator]] with [[TCD]] and [[TDC]].&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
# page 5 of the official 65c816 datasheet: https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf&lt;br /&gt;
# section 2.6 on page 7, lbid.&lt;br /&gt;
# [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/53 page 53]&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Registers]]&lt;br /&gt;
[[Category:65c816 additions]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=DL&amp;diff=21172</id>
		<title>DL</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=DL&amp;diff=21172"/>
		<updated>2026-05-11T23:07:30Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: consolidate redirect&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#redirect [[Direct Page Register]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=DH&amp;diff=21171</id>
		<title>DH</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=DH&amp;diff=21171"/>
		<updated>2026-05-11T23:06:59Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: consolidate redirect&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#redirect [[Direct Page Register]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=SBC&amp;diff=21170</id>
		<title>SBC</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=SBC&amp;diff=21170"/>
		<updated>2026-05-11T15:13:42Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|E9&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|ED&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Addressing|Absolute Long]]&lt;br /&gt;
|EF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page|Direct Page]]&lt;br /&gt;
|E5&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Addressing|Direct Page Indirect]]&lt;br /&gt;
|F2&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long]]&lt;br /&gt;
|E7&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|FD&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Indexed by X]]&lt;br /&gt;
|FF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by Y]]&lt;br /&gt;
|F9&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|F5&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed Indirect by X]]&lt;br /&gt;
|E1&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Indexed by Y]]&lt;br /&gt;
|F1&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long Indexed by Y]]&lt;br /&gt;
|F7&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative]]&lt;br /&gt;
|E3&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative Indirect Indexed by Y]]&lt;br /&gt;
|F3&lt;br /&gt;
|2 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[N Flag|N]]&lt;br /&gt;
|[[V Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[D Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Z Flag|Z]]&lt;br /&gt;
|[[C Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|V&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|C&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SBC&#039;&#039;&#039; (Subtract with Carry/Borrow) is the main 65x subtraction instruction.  The [[accumulator]] serves as both the minuend and where the difference is stored.  The operand serves as the subtrahend.  For example, SBC #6 does &amp;quot;a minus 6&amp;quot; but there is this caveat about the carry flag:&lt;br /&gt;
&lt;br /&gt;
If the [[carry flag]] (aka borrow flag) is clear, one more is subtracted.  As there is no subtract-without-carry instruction, [[SEC]] should be run beforehand or the carry flag should otherwise be ensured to be set, otherwise the difference may be one greater than expected.&lt;br /&gt;
&lt;br /&gt;
The size of the accumulator determines whether this is an 8 or 16 bit operation. If 16-bit and not using [[immediate addressing]], the low-order byte is located at the effective address and the high-order byte at the effective address plus one. &lt;br /&gt;
&lt;br /&gt;
If the difference is negative, the carry flag will be cleared, otherwise it will be set.  If the [[decimal flag]] is set, then [[binary coded decimal]] subtraction is performed, otherwise binary subtraction.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SBC #const&lt;br /&gt;
SBC addr&lt;br /&gt;
SBC long&lt;br /&gt;
SBC dp&lt;br /&gt;
SBC (dp)&lt;br /&gt;
SBC [dp]&lt;br /&gt;
SBC addr, X&lt;br /&gt;
SBC long, X&lt;br /&gt;
SBC addr, Y&lt;br /&gt;
SBC dp, X&lt;br /&gt;
SBC (dp, X)&lt;br /&gt;
SBC (dp), Y&lt;br /&gt;
SBC [dp], Y&lt;br /&gt;
SBC sr, S&lt;br /&gt;
SBC (sr, S), Y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you only need to subtract one, consider [[DEC]] instead.&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
SBC takes an extra cycle for each of the following:&lt;br /&gt;
* if the accumulator is 16 bits wide, in all addressing modes&lt;br /&gt;
* when utilizing the [[direct register]] (opcodes E5, F2, E7, F5, E1, F1, and F7), if the low byte of the direct register is nonzero&lt;br /&gt;
* In both [[Absolute Indexed]] and [[Direct Page Indirect Indexed by Y]] addressing modes if adding an index crosses a [[page]] boundary&lt;br /&gt;
&lt;br /&gt;
Unlike the 65c02, the 65c816 does not have a cycle penalty when subtracting in decimal mode.&lt;br /&gt;
&lt;br /&gt;
In [[Eyes &amp;amp; Lichty]] on page 498, opcode F5 has a &amp;quot;0&amp;quot; superscript typo on the # of cycles column.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[ADC]]&lt;br /&gt;
* [[SBC (SPC700)]]&lt;br /&gt;
* [[SUB (Super FX)]]&lt;br /&gt;
* [[DEX]]&lt;br /&gt;
* [[DEY]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/497 page 497] on SBC&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n189 page 179] on SBC&lt;br /&gt;
* 2.2.2 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n29 page 14] on SBC&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n284 page 271] on SBC&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n140 page 3-91] on SBC&lt;br /&gt;
* snes9x implementation of SBC: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L1133&lt;br /&gt;
* undisbeliever on SBC: https://undisbeliever.net/snesdev/65816-opcodes.html#sbc-subtract-with-borrow-from-accumulator&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#SBC&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.1.1&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group One Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=ORA&amp;diff=21169</id>
		<title>ORA</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=ORA&amp;diff=21169"/>
		<updated>2026-05-11T15:06:52Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|09&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|0D&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Addressing|Absolute Long]]&lt;br /&gt;
|0F&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|05&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect]]&lt;br /&gt;
|12&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long]]&lt;br /&gt;
|07&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|1D&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Indexed by X]]&lt;br /&gt;
|1F&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by Y]]&lt;br /&gt;
|19&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|15&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed Indirect by X]]&lt;br /&gt;
|01&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Indexed by Y]]&lt;br /&gt;
|11&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long Indexed by Y]]&lt;br /&gt;
|17&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative]]&lt;br /&gt;
|03&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative Indirect Indexed by Y]]&lt;br /&gt;
|13&lt;br /&gt;
|2 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ORA&#039;&#039;&#039; is a 65x instruction that performs a logical OR between the datum at the effective address and the [[accumulator]] and stores the disjunction in the accumulator.  The size of the accumulator determines whether 8 or 16 bits are ORed together with it.  If 16-bit and not using [[immediate addressing]], the low-order byte is located at the effective address and the high-order byte at the effective address plus one. &lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ORA #const&lt;br /&gt;
ORA addr&lt;br /&gt;
ORA long&lt;br /&gt;
ORA dp&lt;br /&gt;
ORA (dp)&lt;br /&gt;
ORA [dp]&lt;br /&gt;
ORA addr, X&lt;br /&gt;
ORA long, X&lt;br /&gt;
ORA addr, Y&lt;br /&gt;
ORA dp, X&lt;br /&gt;
ORA (dp, X)&lt;br /&gt;
ORA (dp), Y&lt;br /&gt;
ORA [dp], Y&lt;br /&gt;
ORA sr, S&lt;br /&gt;
ORA (sr, S), Y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* In all [[addressing modes]], ORA takes one extra cycle when the accumulator is 16 bits wide.&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes 05, 12, 07, 15, 01, 11, and 17), ORA takes another extra cycle if the low byte of the [[direct page register]] is nonzero.&lt;br /&gt;
* Both [[Absolute Indexed]] and [[Direct Page Indirect Indexed by Y]] addressing modes have another cycle penalty when indexing crosses a page boundary&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[AND]]&lt;br /&gt;
* [[EOR]]&lt;br /&gt;
* [[OR (Super FX)]]&lt;br /&gt;
* [[XOR (Super FX)]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/471 page 471] on ORA&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n166 page 156] on ORA&lt;br /&gt;
* 2.2.4.2 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n36 page 21] on ORA&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n279 page 266] on ORA&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n128 page 3-79] on ORA&lt;br /&gt;
* snes9x implementation of ORA: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L917&lt;br /&gt;
* undisbeliever on ORA: https://undisbeliever.net/snesdev/65816-opcodes.html#ora-or-accumulator-with-memory&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#ORA&lt;br /&gt;
* Bruce, Clark. http://www.6502.org/tutorials/65c816opcodes.html#6.1.2.1&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group One Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=LSR&amp;diff=21168</id>
		<title>LSR</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=LSR&amp;diff=21168"/>
		<updated>2026-05-11T15:02:58Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Accumulator Addressing|Accumulator]]&lt;br /&gt;
|4A&lt;br /&gt;
|1 byte&lt;br /&gt;
|2 cycles&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|4E&lt;br /&gt;
|3 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|46&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|5E&lt;br /&gt;
|3 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|56&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[N Flag|N]]&lt;br /&gt;
|[[V Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[D Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Z Flag|Z]]&lt;br /&gt;
|[[C Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|0&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|C&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LSR&#039;&#039;&#039; (Logical Shift Right) is a 65x instruction that shifts every bit of a value one bit to the right (division by two).  The most significant bit and [[negative flag]] are cleared.  The least significant bit is shifted into the [[carry flag]].  The previous value of the carry flag is lost (unlike with [[ROR]]).&lt;br /&gt;
&lt;br /&gt;
The size of the accumulator determines how many bits are shifted (8 or 16) not including the clearing zero and carry flag.  If 16-bit and not using [[accumulator addressing]], the low-order byte is located at the effective address and the high-order byte at the effective address plus one. &lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
LSR&lt;br /&gt;
LSR A&lt;br /&gt;
LSR addr&lt;br /&gt;
LSR dp&lt;br /&gt;
LSR addr, X&lt;br /&gt;
LSR dp, X&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* Except in [[accumulator addressing]], LSR takes an extra two cycles when the accumulator is 16 bits wide&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes 46 and 56), LSR takes another extra cycle if the low byte of the [[direct page register]] is nonzero.&lt;br /&gt;
&lt;br /&gt;
[[File:816_lsr.png]]&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[ASL]]&lt;br /&gt;
* [[LSR (SPC700)]]&lt;br /&gt;
* [[LSR (Super FX)]]&lt;br /&gt;
* [[DIV2]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/465 page 465] on LSR&lt;br /&gt;
* lbid [https://archive.org/details/0893037893ProgrammingThe65816/page/191 page 191], before &amp;amp; after diagram of LSR&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n162 page 152] on LSR&lt;br /&gt;
* 10.1 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n169 page 148] on LSR&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n278 page 265] on LSR&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n125 page 3-76] on LSR&lt;br /&gt;
* snes9x implementation of LSR: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L862&lt;br /&gt;
* undisbeliever on LSR: https://undisbeliever.net/snesdev/65816-opcodes.html#lsr-logical-shift-right&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#LSR&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.3&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group Two Instructions]]&lt;br /&gt;
[[Category:Read-Modify-Write Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=LDY&amp;diff=21167</id>
		<title>LDY</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=LDY&amp;diff=21167"/>
		<updated>2026-05-11T15:01:56Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|A0&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|AC&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|A4&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|BC&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|B4&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LDY&#039;&#039;&#039; (Load Y) is a 65x instruction that loads a value into the [[Y index register]].  The size of the index registers determines whether this is an 8 or 16 bit operation.  If 16-bit and not using [[immediate addressing]], the low-order byte is loaded from the effective address and the high-order byte from the effective address plus one. &lt;br /&gt;
&lt;br /&gt;
In [[immediate addressing]] only, LDY takes a total of 3 bytes when the index registers are 16 bits wide.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
LDY #const&lt;br /&gt;
LDY addr&lt;br /&gt;
LDY dp&lt;br /&gt;
LDY addr, X&lt;br /&gt;
LDY dp, X&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* In all [[addressing mode]]s, LDY takes an extra cycle when the index registers are 16 bits wide&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes A4 and B4), LDY takes another extra cycle if the low byte of the [[direct page register]] is nonzero.&lt;br /&gt;
* In [[Absolute Indexed, Y Addressing]] only, LDY takes an another extra cycle if adding the index crosses a page boundary&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[STY]]&lt;br /&gt;
* [[LDA]]&lt;br /&gt;
* [[LDX]]&lt;br /&gt;
* [[TAY]]&lt;br /&gt;
* [[TXY]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/n490 page 464] on LDY&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n161 page 151] on LDY&lt;br /&gt;
* 7.1 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n114 page 96] on LDY&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n277 page 264] on LDY&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n123 page 3-74] on LDY&lt;br /&gt;
* snes9x implementation of LDY: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L817&lt;br /&gt;
* undisbeliever on LDY: https://undisbeliever.net/snesdev/65816-opcodes.html#ldy-load-index-register-y-from-memory&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#LDY&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group Three Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Load/Store Instructions]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=LDX&amp;diff=21166</id>
		<title>LDX</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=LDX&amp;diff=21166"/>
		<updated>2026-05-11T15:00:25Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|A2&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|AE&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|A6&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by Y]]&lt;br /&gt;
|BE&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by Y]]&lt;br /&gt;
|B6&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LDX&#039;&#039;&#039; (Load X) is a 65x instruction that loads a value into the [[X index register]].  The size of the index registers determines whether this is an 8 or 16 bit operation.  If 16-bit and not using [[immediate addressing]], the low-order byte is loaded from the effective address and the high-order byte from the effective address plus one. &lt;br /&gt;
&lt;br /&gt;
In [[immediate addressing]] only, LDX is a total of 3 bytes long when the index registers are 16 bits wide.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
LDX #const&lt;br /&gt;
LDX addr&lt;br /&gt;
LDX dp&lt;br /&gt;
LDX addr, Y&lt;br /&gt;
LDX dp, Y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* In all [[addressing mode]]s, LDX takes an extra cycle when the index registers are 16 bits wide&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes A6 and B6), LDX takes another extra cycle if the low byte of the [[direct page register]] is nonzero.&lt;br /&gt;
* In [[Absolute Indexed, Y Addressing]] only, LDX takes an another extra cycle if adding the index crosses a page boundary&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[STX]]&lt;br /&gt;
* [[LDA]]&lt;br /&gt;
* [[LDY]]&lt;br /&gt;
* [[TAX]]&lt;br /&gt;
* [[TYX]]&lt;br /&gt;
* [[TSX]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/463 page 463] on LDX&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n160 page 150] on LDX&lt;br /&gt;
* 7.0 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n114 page 96] on LDX&lt;br /&gt;
* [https://archive.org/details/mos_microcomputers_programming_manual/page/n219 B-18], lbid.&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n277 page 264] on LDX&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n121 page 3-72] on LDX&lt;br /&gt;
* snes9x implementation of LDX: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L772&lt;br /&gt;
* undisbeliever on LDX: https://undisbeliever.net/snesdev/65816-opcodes.html#ldx-load-index-register-x-from-memory&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#LDX&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group Two Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Load/Store Instructions]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=LDA&amp;diff=21165</id>
		<title>LDA</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=LDA&amp;diff=21165"/>
		<updated>2026-05-11T14:59:05Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|A9&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|AD&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long]]&lt;br /&gt;
|AF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|A5&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect]]&lt;br /&gt;
|B2&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long]]&lt;br /&gt;
|A7&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|BD&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Indexed by X]]&lt;br /&gt;
|BF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by Y]]&lt;br /&gt;
|B9&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|B5&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed Indirect by X]]&lt;br /&gt;
|A1&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Indexed by Y]]&lt;br /&gt;
|B1&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long Indexed by Y]]&lt;br /&gt;
|B7&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative]]&lt;br /&gt;
|A3&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative Indirect Indexed by Y]]&lt;br /&gt;
|B3&lt;br /&gt;
|2 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LDA&#039;&#039;&#039; (LoaD Accumulator) is a 65x instruction that loads a value into the accumulator.  The size of the accumulator determines whether this is an 8 or 16 bit operation.  If 16-bit and not using [[immediate addressing]], the low-order byte is loaded from the effective address and the high-order byte from the effective address plus one. &lt;br /&gt;
&lt;br /&gt;
In [[immediate addressing]] only, LDA is a total of 3 bytes long when the accumulator is 16 bits wide.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
LDA #const&lt;br /&gt;
LDA addr&lt;br /&gt;
LDA long&lt;br /&gt;
LDA dp&lt;br /&gt;
LDA (dp)&lt;br /&gt;
LDA [dp]&lt;br /&gt;
LDA addr, X&lt;br /&gt;
LDA long, X&lt;br /&gt;
LDA addr, Y&lt;br /&gt;
LDA dp, X&lt;br /&gt;
LDA (dp, X)&lt;br /&gt;
LDA (dp), Y&lt;br /&gt;
LDA [dp], Y&lt;br /&gt;
LDA sr, S&lt;br /&gt;
LDA (sr, S), Y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to load zero into the [[accumulator]], [[TDC]] may be a better choice, but only if the [[direct page register]] is zero.&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* In all [[addressing modes]], LDA takes one extra cycle when the accumulator is 16 bits wide.&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes A5, B2, A7, B5, A1, B1, and B7), LDA takes another extra cycle if the low byte of the [[direct page register]] is nonzero.&lt;br /&gt;
* In both the [[Absolute Indexed]] and the [[Direct Page Indirect Indexed by Y]] admodes, LDA takes an extra cycle if adding the index crosses a page boundary.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[STA]]&lt;br /&gt;
* [[LDX]]&lt;br /&gt;
* [[LDY]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/462 page 462] on LDA&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n159 page 149] on LDA&lt;br /&gt;
* 2.1.1 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n19 page 4] on LDA&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n276 page 263] on LDA&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n120 page 3-71] on LDA&lt;br /&gt;
* snes9x implementation of LDA: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L678&lt;br /&gt;
* undisbeliever on LDA: https://undisbeliever.net/snesdev/65816-opcodes.html#lda-load-accumulator-from-memory&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#LDA&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group One Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Load/Store Instructions]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=INC&amp;diff=21164</id>
		<title>INC</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=INC&amp;diff=21164"/>
		<updated>2026-05-11T14:55:50Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Accumulator Addressing | Accumulator]]&lt;br /&gt;
|1A&lt;br /&gt;
|1 byte&lt;br /&gt;
|2 cycles&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Addressing | Absolute]]&lt;br /&gt;
|EE&lt;br /&gt;
|3 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing | Direct Page]]&lt;br /&gt;
|E6&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|FE&lt;br /&gt;
|3 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|F6&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[N Flag|N]]&lt;br /&gt;
|[[V Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[D Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Z Flag|Z]]&lt;br /&gt;
|[[C Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;INC&#039;&#039;&#039; (Increment) is a 65x instruction that increments the value in the location specified by one.  The size of the [[accumulator]] determines whether this is an 8 or 16 bit operation.  If 16-bit and not using [[accumulator addressing]], the low byte is located at the effective address and the high byte at the effective address plus one.  An alternate mnemonic when the operand is the accumulator is &amp;quot;INA.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
INC ignores the [[decimal mode flag]] and the [[carry flag]].&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
INC&lt;br /&gt;
INC A&lt;br /&gt;
INA&lt;br /&gt;
INC addr&lt;br /&gt;
INC dp&lt;br /&gt;
INC addr, X&lt;br /&gt;
INC dp, X&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To test for wraparound, examine the [[zero flag]].  If you need to add two or more to the [[accumulator]], consider [[ADC]] instead of INC.&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* Except in [[accumulator addressing]], INC takes two extra cycles when the accumulator is 16 bits wide.&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes E6 and F6), INC takes an extra cycle if the low byte of the [[direct page register]] is nonzero.&lt;br /&gt;
&lt;br /&gt;
Although the NMOS 6502 does have INC, it does not work on the accumulator.  The NES CPU is one such system that lacks that addressing mode for INC.  When porting code to the 65c816, utilizing INC more often instead of ADC can make code smaller and faster.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[INX]]&lt;br /&gt;
* [[INY]]&lt;br /&gt;
* [[DEC]]&lt;br /&gt;
* [[INC (SPC700)]]&lt;br /&gt;
* [[INC (Super FX)]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/456 page 456] on INC&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n152 page 142] on INC&lt;br /&gt;
* 10.7 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n176 page 155] on INC&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n273 page 260] on INC&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n114 page 3-65] on INC&lt;br /&gt;
* snes9x implementation of INC: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L627&lt;br /&gt;
* undisbeliever on INC: https://undisbeliever.net/snesdev/65816-opcodes.html#inc-increment&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#INC&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.1.3&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group Two Instructions]]&lt;br /&gt;
[[Category:Read-Modify-Write Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=Direct_Page_Indirect_Indexed,_Y&amp;diff=21163</id>
		<title>Direct Page Indirect Indexed, Y</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=Direct_Page_Indirect_Indexed,_Y&amp;diff=21163"/>
		<updated>2026-05-11T14:54:37Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: created page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#redirect [[Direct Page Indirect Indexed, Y Addressing]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=EOR&amp;diff=21162</id>
		<title>EOR</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=EOR&amp;diff=21162"/>
		<updated>2026-05-11T14:53:43Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|49&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|4D&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Addressing|Absolute Long]]&lt;br /&gt;
|4F&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|45&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect]]&lt;br /&gt;
|52&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long]]&lt;br /&gt;
|47&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|5D&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Indexed by X]]&lt;br /&gt;
|5F&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by Y]]&lt;br /&gt;
|59&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|55&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed Indirect by X]]&lt;br /&gt;
|41&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Indexed by Y]]&lt;br /&gt;
|51&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long Indexed by Y]]&lt;br /&gt;
|57&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative]]&lt;br /&gt;
|43&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative Indirect Indexed by Y]]&lt;br /&gt;
|53&lt;br /&gt;
|2 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;EOR&#039;&#039;&#039; is a 65x instruction that performs a bitwise [https://mathworld.wolfram.com/XOR.html exclusive or] between its operand and the accumulator.  The sum is stored in the [[accumulator]].  The size of the accumulator determines whether 8 or 16 bits are EORed together with it.  If 16-bit and not using [[immediate addressing]], the low-order byte is located at the effective address and the high-order byte at the effective address plus one. &lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
EOR #const&lt;br /&gt;
EOR addr&lt;br /&gt;
EOR long&lt;br /&gt;
EOR dp&lt;br /&gt;
EOR (dp)&lt;br /&gt;
EOR [dp]&lt;br /&gt;
EOR addr, X&lt;br /&gt;
EOR long, X&lt;br /&gt;
EOR addr, Y&lt;br /&gt;
EOR dp, X&lt;br /&gt;
EOR (dp, X)&lt;br /&gt;
EOR (dp), Y&lt;br /&gt;
EOR [dp], Y&lt;br /&gt;
EOR sr, S&lt;br /&gt;
EOR (sr, S), Y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One example usage of EOR is to flip all the bits of the accumulator:&amp;lt;sup&amp;gt;[10]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
EOR #$FFFF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* In all [[addressing modes]], EOR takes one extra cycle when the accumulator is 16 bits wide.&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes 45, 52, 47, 55, 41, 51, and 57), EOR takes one additional cycle if the low byte of the [[direct page register]] is nonzero.&lt;br /&gt;
* In both [[Absolute Indexed]] and [[Direct Page Indirect Indexed, Y]] admodes, EOR takes an extra cycle if adding the index crosses a page boundary.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[ORA]]&lt;br /&gt;
* [[AND]]&lt;br /&gt;
* [[EOR (SPC700)]]&lt;br /&gt;
* [[OR (SPC700)]]&lt;br /&gt;
* [[XOR (Super FX)]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
# [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/454 page 454] on EOR&lt;br /&gt;
# [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n151 page 141] on EOR&lt;br /&gt;
# 2.2.4.3 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n36 page 21] on EOR&lt;br /&gt;
# [[Carr]], [https://archive.org/details/6502UsersManual/page/n272 page 259] on EOR&lt;br /&gt;
# [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n112 page 3-63] on EOR&lt;br /&gt;
# snes9x implementation of EOR: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L533&lt;br /&gt;
# undisbeliever on EOR: https://undisbeliever.net/snesdev/65816-opcodes.html#eor-exclusive-or-accumulator-with-memory&lt;br /&gt;
# Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#EOR&lt;br /&gt;
# Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.2.1&lt;br /&gt;
# Carr, [https://archive.org/details/6502UsersManual/page/n273 page 260]&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group One Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=DEC&amp;diff=21161</id>
		<title>DEC</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=DEC&amp;diff=21161"/>
		<updated>2026-05-11T14:49:58Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Accumulator Addressing|Accumulator]]&lt;br /&gt;
|3A&lt;br /&gt;
|1 byte&lt;br /&gt;
|2 cycles&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|CE&lt;br /&gt;
|3 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing | Direct Page]]&lt;br /&gt;
|C6&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|DE&lt;br /&gt;
|3 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|D6&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;DEC&#039;&#039;&#039; (Decrement) is a 65x instruction that decrements the value in the location specified by the operand by one.  The size of the [[accumulator]] determines whether this is an 8 or 16 bit operation.  If 16-bit and not using [[accumulator addressing]], the low byte is located at the effective address and the high byte at the effective address plus one.  An alternate mnemonic when the operand is the accumulator is &amp;quot;DEA.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
DEC ignores the [[decimal mode flag]] and the [[carry flag]].&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DEC&lt;br /&gt;
DEC A&lt;br /&gt;
DEA&lt;br /&gt;
DEC addr&lt;br /&gt;
DEC dp&lt;br /&gt;
DEC addr, X&lt;br /&gt;
DEC dp, X&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you need to subtract two or more from the [[accumulator]], consider [[SBC]] instead.&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* Except in [[accumulator addressing]], DEC takes two extra cycles when the accumulator is 16 bits wide.&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes C6 and D6), DEC takes an extra cycle when the low byte of the [[direct page register]] is nonzero&lt;br /&gt;
&lt;br /&gt;
Although the NMOS 6502 does have DEC, it does not work on the accumulator.  The NES CPU is one such system that lacks that addressing mode for DEC.  When porting code to the 65c816, utilizing DEC more often instead of SBC can make code smaller and faster.&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[INC]]&lt;br /&gt;
* [[DEX]]&lt;br /&gt;
* [[DEY]]&lt;br /&gt;
* [[DEC (SPC700)]]&lt;br /&gt;
* [[DEC (Super FX)]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/451 page 451] on DEC&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n148 page 138] on DEC&lt;br /&gt;
* 10.8 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n176 page 155] on DEC&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n270 page 257] on DEC&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n109 page 3-60] on DEC&lt;br /&gt;
* snes9x implementation of DEC: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L482&lt;br /&gt;
* undisbeliever on DEC: https://undisbeliever.net/snesdev/65816-opcodes.html#dec-decrement&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#DEC&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.1.3&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group Two Instructions]]&lt;br /&gt;
[[Category:Read-Modify-Write Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=CMP&amp;diff=21160</id>
		<title>CMP</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=CMP&amp;diff=21160"/>
		<updated>2026-05-11T14:45:33Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:50%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|C9&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|CD&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long]]&lt;br /&gt;
|CF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|C5&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect]]&lt;br /&gt;
|D2&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long]]&lt;br /&gt;
|C7&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|DD&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Long Indexed by X]]&lt;br /&gt;
|DF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by Y]]&lt;br /&gt;
|D9&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|D5&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed Indirect by X]]&lt;br /&gt;
|C1&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Indexed by Y]]&lt;br /&gt;
|D1&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indirect Long Indexed by Y]]&lt;br /&gt;
|D7&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative]]&lt;br /&gt;
|C3&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Relative Indirect Indexed by Y]]&lt;br /&gt;
|D3&lt;br /&gt;
|2 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|C&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CMP&#039;&#039;&#039; (Compare) is a 65x instruction that compares the value of the [[accumulator]] to something.  Internally, this is done via a subtraction, but the difference is discarded.  Thus, the purpose of CMP is to setup the flags.  The accumulator serves as the minuend and the operand serves as the subtrahend.  For example, CMP #6 does &amp;quot;a minus 6&amp;quot; internally.  CMP only does unsigned comparisons.  In [[immediate addressing]] only, CMP is a total of 3 bytes long when the accumulator is 16 bits wide.  Unlike [[SBC]], the [[carry flag]] does not affect CMP.&lt;br /&gt;
&lt;br /&gt;
The size of the accumulator determines whether this is an 8 or 16 bit operation. If 16-bit and not using [[immediate addressing]], the low-order byte is located at the effective address and the high-order byte at the effective address plus one.&lt;br /&gt;
&lt;br /&gt;
If the subtraction required a borrow, the carry flag is cleared (otherwise it is set).&lt;br /&gt;
&lt;br /&gt;
The [[decimal mode flag]] has no effect on the behavior of CMP.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CMP #const&lt;br /&gt;
CMP addr&lt;br /&gt;
CMP long&lt;br /&gt;
CMP dp&lt;br /&gt;
CMP (dp)&lt;br /&gt;
CMP [dp]&lt;br /&gt;
CMP addr, X&lt;br /&gt;
CMP long, X&lt;br /&gt;
CMP addr, Y&lt;br /&gt;
CMP dp, X&lt;br /&gt;
CMP (dp, X)&lt;br /&gt;
CMP (dp), Y&lt;br /&gt;
CMP [dp], Y&lt;br /&gt;
CMP sr, S&lt;br /&gt;
CMP (sr, S), Y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
CPA is an alternative mnemonic.  The 65c816 datasheet mentions an alternative mnemonic &amp;quot;CMA&amp;quot; which might be an alias for &amp;quot;CMP #0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* In all [[addressing modes]], CMP takes an extra cycle when the accumulator is 16 bits wide&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes C5, D2, C7, D5, C1, D1, D7), CMP takes an extra cycle when the low byte of the [[direct page register]] is nonzero&lt;br /&gt;
* In both [[Absolute Indexed]] and [[Direct Page Indirect Indexed by Y]], CMP takes an extra cycle if adding the index crosses a page boundary&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[CPX]]&lt;br /&gt;
* [[CPY]]&lt;br /&gt;
* [[CMP (Super FX)]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/445 page 445] on CMP&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n144 page 134] on CMP&lt;br /&gt;
* 4.2.1 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n60 page 45] on CMP&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n268 page 255] on CMP&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n105 page 3-56] on CMP&lt;br /&gt;
* snes9x implementation of CMP: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L304&lt;br /&gt;
* undisbeliever on CMP: https://undisbeliever.net/snesdev/65816-opcodes.html#cmp-compare-accumulator-with-memory&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#CMP&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.1.2&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group One Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Compare Instructions]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=BRK&amp;diff=21159</id>
		<title>BRK</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=BRK&amp;diff=21159"/>
		<updated>2026-05-11T14:41:04Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: moved cycle penalty to bottom&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Stack Addressing|Stack]] (Interrupt)&lt;br /&gt;
|00&lt;br /&gt;
|2 bytes&lt;br /&gt;
|8 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]] / [[Break Flag|B]]&lt;br /&gt;
|[[D Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|[[65c816 native mode]]&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|+&lt;br /&gt;
|[[6502 emulation mode]]&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BRK&#039;&#039;&#039; (Break) is a 65x instruction that triggers a non-maskable software interrupt ([[Non-Maskable Interrupt|NMI]]).  The byte following the opcode is called the [[signature byte]].  The state of the [[interrupt disable flag]] has no effect on the behavior of BRK although it will be set after BRK runs.&lt;br /&gt;
&lt;br /&gt;
In [[native mode]] the [[program bank register]] is pushed to the [[stack]].  Then the [[program counter]] is incremented by two and then pushed to the stack.  Then the [[status register]] (with the [[break flag]] set, if in emulation mode) is pushed to the stack.  Then the interrupt disable flag is set.  In native mode, the program bank register is then cleared.&lt;br /&gt;
&lt;br /&gt;
Control is routed to the BRK handler, whose address is stored at the BRK vector:&lt;br /&gt;
* In native mode, this vector is at $00:FFE6.&lt;br /&gt;
* In emulation mode, this vector is at $FFFE.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BRK&lt;br /&gt;
BRK sig&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the signature byte was omitted from the assembler source, then it ends up serving double duty as the opcode of the next instruction.  In this case the [[interrupt handler]] must decrement the [[return address]] on the [[stack]] so that the eventual [[RTI]] does not cause [[derailment]].&lt;br /&gt;
&lt;br /&gt;
[[File:brk.png]]&lt;br /&gt;
&lt;br /&gt;
BRK used to be considered a one-byte instruction in an early datasheet.  On the NMOS 6502, BRK does not affect the decimal flag, but this likely only affects porting code from systems other than the NES because the NES does not have decimal mode anyway.&lt;br /&gt;
&lt;br /&gt;
==== Cycle Skipped ====&lt;br /&gt;
* BRK takes one fewer cycle in [[emulation mode]] as it doesn&#039;t need to push the [[program counter bank register]] to the [[stack]].&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[RTI]]&lt;br /&gt;
* [[BRK (SPC700)]]&lt;br /&gt;
* [[NMI]]&lt;br /&gt;
* [[IRQ]]&lt;br /&gt;
* [[COP]]&lt;br /&gt;
* [[WDM]]&lt;br /&gt;
* [[CLD]]&lt;br /&gt;
* [[SEI]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/436 page 436] on BRK&lt;br /&gt;
* Figure 13.3, Break Signature Byte Illustration, lbid, [https://archive.org/details/0893037893ProgrammingThe65816/page/n282 page 256]&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n136 page 126] on BRK&lt;br /&gt;
* 9.11 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n164 page 144] on BRK&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n265 page 252] on BRK&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n98 page 3-49] on BRK&lt;br /&gt;
* snes9x implementation of BRK: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L2547&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#BRK&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c02opcodes.html#6&lt;br /&gt;
* https://undisbeliever.net/snesdev/65816-opcodes.html#software-interrupts&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;br /&gt;
[[Category:Two-byte Instructions]]&lt;br /&gt;
[[Category:Single Admode Mnemonics]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=BIT&amp;diff=21158</id>
		<title>BIT</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=BIT&amp;diff=21158"/>
		<updated>2026-05-11T14:37:49Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|89&lt;br /&gt;
|2/3 bytes&lt;br /&gt;
|2 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|2C&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|24&lt;br /&gt;
|2 bytes&lt;br /&gt;
|3 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|3C&lt;br /&gt;
|3 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|34&lt;br /&gt;
|2 bytes&lt;br /&gt;
|4 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|Addressing Mode&lt;br /&gt;
|[[Negative Flag|N]]&lt;br /&gt;
|[[Overflow Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[Decimal Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Zero Flag|Z]]&lt;br /&gt;
|[[Carry Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|[[Immediate]]&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|+&lt;br /&gt;
|other&lt;br /&gt;
|N&lt;br /&gt;
|V&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BIT&#039;&#039;&#039; is a 65x instruction that performs a logical AND operation between the [[accumulator]] and memory without storing the conjunction.  If the conjunction is zero, the [[zero flag]] is set, otherwise it is cleared.&lt;br /&gt;
&lt;br /&gt;
The size of the accumulator determines whether this is an 8 or 16 bit operation. If 16-bit and not using [[immediate addressing]], the low-order byte is located at the effective address and the high-order byte at the effective address plus one.&lt;br /&gt;
&lt;br /&gt;
Except in [[immediate addressing]], the most significant bit of the data located at the effective address (plus zero or one) is moved into the [[negative flag]], and the second most significant bit of that data is moved into the [[overflow flag]].  BIT is often used right before a conditional branch instruction like [[BVC]] or [[BVS]].&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BIT #const&lt;br /&gt;
BIT addr&lt;br /&gt;
BIT dp&lt;br /&gt;
BIT addr, X&lt;br /&gt;
BIT dp, X&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* BIT takes an extra cycle when the accumulator is 16 bits wide, in all [[addressing modes]]&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes 24 and 34), BIT takes an extra cycle when the low byte of the [[direct page register]] is nonzero&lt;br /&gt;
* In [[Absolute Indexed, X Addressing]] only, BIT takes an extra cycle when adding the index crosses a [[page]] boundary&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[AND]]&lt;br /&gt;
* [[BPL]]&lt;br /&gt;
* [[BNE]]&lt;br /&gt;
* [[BCC]]&lt;br /&gt;
* [[BCS]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/431 page 431] on BIT&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n131 page 121] on BIT&lt;br /&gt;
* 4.2.2.1 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n62 page 47] on BIT&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n262 page 249] on BIT&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n94 page 3-45] on BIT&lt;br /&gt;
* snes9x implementation of BIT: https://github.com/snes9xgit/snes9x/blob/master/cpuops.cpp#L265&lt;br /&gt;
* undisbeliever on BIT: https://undisbeliever.net/snesdev/65816-opcodes.html#bit-test-memory-bits-against-accumulator&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#BIT&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.2.2&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group Three Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
	<entry>
		<id>https://sneslab.net/mw/index.php?title=ASL&amp;diff=21157</id>
		<title>ASL</title>
		<link rel="alternate" type="text/html" href="https://sneslab.net/mw/index.php?title=ASL&amp;diff=21157"/>
		<updated>2026-05-11T14:34:43Z</updated>

		<summary type="html">&lt;p&gt;Xetheria: /* Cycle Penalties */ opcodes for dp admodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:40%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|Basic Info&lt;br /&gt;
|+&lt;br /&gt;
|&#039;&#039;&#039;Addressing Mode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Opcode&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Length&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Speed&#039;&#039;&#039;&lt;br /&gt;
|+&lt;br /&gt;
|[[Accumulator Addressing|Accumulator]]&lt;br /&gt;
|0A&lt;br /&gt;
|1 byte&lt;br /&gt;
|2 cycles&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute]]&lt;br /&gt;
|0E&lt;br /&gt;
|3 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Addressing|Direct Page]]&lt;br /&gt;
|06&lt;br /&gt;
|2 bytes&lt;br /&gt;
|5 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Absolute Indexed by X]]&lt;br /&gt;
|1E&lt;br /&gt;
|3 bytes&lt;br /&gt;
|7 cycles*&lt;br /&gt;
|+&lt;br /&gt;
|[[Direct Page Indexed by X]]&lt;br /&gt;
|16&lt;br /&gt;
|2 bytes&lt;br /&gt;
|6 cycles*&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:right;clear:right;width:30%&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;9&amp;quot;|Flags Affected&lt;br /&gt;
|+&lt;br /&gt;
|[[N Flag|N]]&lt;br /&gt;
|[[V Flag|V]]&lt;br /&gt;
|[[M Flag|M]]&lt;br /&gt;
|[[X Flag|X]]&lt;br /&gt;
|[[D Flag|D]]&lt;br /&gt;
|[[I Flag|I]]&lt;br /&gt;
|[[Z Flag|Z]]&lt;br /&gt;
|[[C Flag|C]]&lt;br /&gt;
|+&lt;br /&gt;
|N&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|.&lt;br /&gt;
|Z&lt;br /&gt;
|C&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ASL&#039;&#039;&#039; (Arithmetic Shift Left) is a 65x instruction that shifts every bit of a value left one bit (multiplication by two).  The least significant bit is cleared.  The most significant bit is shifted into the [[carry flag]].  The previous value of the carry flag is lost (unlike with [[ROL]]).&lt;br /&gt;
&lt;br /&gt;
The size of the accumulator determines how many bits are shifted (8 or 16) not including the clearing zero and carry flag.  If 16-bit and not using [[accumulator addressing]], the low-order byte is located at the effective address and the high-order byte at the effective address plus one.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ASL&lt;br /&gt;
ASL A&lt;br /&gt;
ASL addr&lt;br /&gt;
ASL dp&lt;br /&gt;
ASL addr, X&lt;br /&gt;
ASL dp, X&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cycle Penalties ====&lt;br /&gt;
* Except in [[accumulator addressing]], ASL takes two extra cycles when the accumulator is 16 bits wide&lt;br /&gt;
* In [[direct page addressing]] modes (opcodes 06 and 16), ASL takes another extra cycle if the low byte of the [[direct page register]] is nonzero.&lt;br /&gt;
&lt;br /&gt;
[[File:816_asl.png]]&lt;br /&gt;
&lt;br /&gt;
=== See Also ===&lt;br /&gt;
* [[LSR]]&lt;br /&gt;
* [[ASL (SPC700)]]&lt;br /&gt;
* [[ROL]]&lt;br /&gt;
&lt;br /&gt;
=== External Links ===&lt;br /&gt;
* [[Eyes &amp;amp; Lichty]], [https://archive.org/details/0893037893ProgrammingThe65816/page/427 page 427] on ASL&lt;br /&gt;
* lbid [https://archive.org/details/0893037893ProgrammingThe65816/page/190 page 190], before &amp;amp; after diagram of ASL&lt;br /&gt;
* [[Labiak]], [https://archive.org/details/Programming_the_65816/page/n127 page 117] on ASL&lt;br /&gt;
* 10.2 on [[MCS6500 Manual]], [https://archive.org/details/mos_microcomputers_programming_manual/page/n170 page 149] on ASL&lt;br /&gt;
* [https://archive.org/details/mos_microcomputers_programming_manual/page/n205 B-4], lbid.&lt;br /&gt;
* [[Carr]], [https://archive.org/details/6502UsersManual/page/n260 page 247] on ASL&lt;br /&gt;
* [[Leventhal]], [https://archive.org/details/6502-assembly-language-programming/page/n90 page 3-41] on ASL&lt;br /&gt;
* undisbeliever on ASL: https://undisbeliever.net/snesdev/65816-opcodes.html#asl-arithmetic-shift-left&lt;br /&gt;
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#ASL&lt;br /&gt;
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.1.3&lt;br /&gt;
&lt;br /&gt;
[[Category:ASM]]&lt;br /&gt;
[[Category:Group Two Instructions]]&lt;br /&gt;
[[Category:Read-Modify-Write Instructions]]&lt;br /&gt;
[[Category:Inherited from 6502]]&lt;/div&gt;</summary>
		<author><name>Xetheria</name></author>
	</entry>
</feed>