<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://gbdev.gg8.se/wiki/index.php?action=history&amp;feed=atom&amp;title=Equivalents_to_6502_instructions</id>
		<title>Equivalents to 6502 instructions - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://gbdev.gg8.se/wiki/index.php?action=history&amp;feed=atom&amp;title=Equivalents_to_6502_instructions"/>
		<link rel="alternate" type="text/html" href="https://gbdev.gg8.se/wiki/index.php?title=Equivalents_to_6502_instructions&amp;action=history"/>
		<updated>2026-04-16T04:28:37Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.25.1</generator>

	<entry>
		<id>https://gbdev.gg8.se/wiki/index.php?title=Equivalents_to_6502_instructions&amp;diff=866&amp;oldid=prev</id>
		<title>PinoBatch: In #gbdev2: &lt;DarkerBit&gt; Ooops I accidentally 6502</title>
		<link rel="alternate" type="text/html" href="https://gbdev.gg8.se/wiki/index.php?title=Equivalents_to_6502_instructions&amp;diff=866&amp;oldid=prev"/>
				<updated>2019-03-29T16:26:54Z</updated>
		
		<summary type="html">&lt;p&gt;In #gbdev2: &amp;lt;DarkerBit&amp;gt; Ooops I accidentally 6502&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Many new Game Boy programmers have experience on a platform with a 6502 family (6502, 6507, 6510, 65C02, 65816, or HuC6280) processor. These include Apple II, Atari 8-bit (2600 VCS, 800, 5200, 7800 ProSystem, Lynx), Nintendo (NES/Famicom, Super NES/Super Famicom), and TurboGrafx-16/PC Engine. To help these programmers adapt, this table lists the closest opcode in the Game Boy CPU to each instruction in a WDC/Rockwell 65C02 CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 65C02 instruction || SM83 instruction || Notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;adc&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;adc&amp;lt;/code&amp;gt; || See also &amp;lt;code&amp;gt;add&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; || Clears carry&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asl&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;sla&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;add a&amp;lt;/code&amp;gt; || It always stood for '''A'''dd to '''S'''e'''L'''f&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bbr&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;bit&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;jr z&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bbs&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;bit&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;jr nz&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bcc&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;jr nc&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bcs&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;jr c&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;beq&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;jr z&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bit&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;bit&amp;lt;/code&amp;gt; || Tests the argument against a given bit, not the bits set in A&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bmi&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;bit 7&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;jr nz&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bne&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;jr nz&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bpl&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;bit 7&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;jr z&amp;lt;/code&amp;gt; || If using to test a counter for wrapping from $00 to $FF, &amp;lt;code&amp;gt;dec b&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;jr nz&amp;lt;/code&amp;gt; is more commonly used.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bra&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;jr&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;brk&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;rst&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bvc&amp;lt;/code&amp;gt; || No direct equivalent || rowspan=&amp;quot;2&amp;quot; | Replacement uses &amp;lt;code&amp;gt;xor&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bit 7&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bvs&amp;lt;/code&amp;gt; || No direct equivalent&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;clc&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;scf&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;ccf&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;or a&amp;lt;/code&amp;gt; also clears Z. Less needed in general because &amp;lt;code&amp;gt;add&amp;lt;/code&amp;gt; exists.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;cld&amp;lt;/code&amp;gt; || No direct equivalent || Skip &amp;lt;code&amp;gt;daa&amp;lt;/code&amp;gt; after &amp;lt;code&amp;gt;add&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;sub&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;cli&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ei&amp;lt;/code&amp;gt; || Also enables vblank if set in LCDC, as Game Boy does not use NMI&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;clv&amp;lt;/code&amp;gt; || No direct equivalent || No SO pin. If using with &amp;lt;code&amp;gt;bvc&amp;lt;/code&amp;gt; to simulate &amp;lt;code&amp;gt;bra&amp;lt;/code&amp;gt;, use &amp;lt;code&amp;gt;jr&amp;lt;/code&amp;gt; without a condition.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;cmp&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;cp&amp;lt;/code&amp;gt; || Carry sense is inverted&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;cpx&amp;lt;/code&amp;gt; || No direct equivalent || rowspan=&amp;quot;2&amp;quot; | Load a value into A and compare it to B, C, etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;cpy&amp;lt;/code&amp;gt; || No direct equivalent&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dec&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;dec&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dex&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;dec b&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dey&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;dec c&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;eor&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;xor&amp;lt;/code&amp;gt; || Clears carry&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;inc&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;inc&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;inx&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;inc b&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;iny&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;inc c&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;jmp&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;jp&amp;lt;/code&amp;gt; || Can be made conditional&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;jsr&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;call&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;lda&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld a&amp;lt;/code&amp;gt; || Does not change Z&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ldx&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld b&amp;lt;/code&amp;gt; || rowspan=&amp;quot;2&amp;quot; | Does not change Z; accessing arrays is [[Struct|very different]]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ldy&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld c&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;lsr&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;srl&amp;lt;/code&amp;gt; || See also &amp;lt;code&amp;gt;sra&amp;lt;/code&amp;gt; which copies bit 7 to carry first&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nop&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;nop&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ora&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; || Clears carry&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;pha&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;push af&amp;lt;/code&amp;gt; || rowspan=&amp;quot;2&amp;quot; | Only pairs of registers can be pushed or popped. BC, DE, and HL are more commonly pushed or popped.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;php&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;push af&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;phx&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;push bc&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;phy&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;push bc&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;pla&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;pop af&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;plp&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;pop af&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;plx&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;pop bc&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ply&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;pop bc&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;rol&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;rla&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rl&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;adc a&amp;lt;/code&amp;gt; || See also &amp;lt;code&amp;gt;rlc&amp;lt;/code&amp;gt; which copies bit 7 to carry first&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;rmb&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;res&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ror&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;rra&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rr&amp;lt;/code&amp;gt; || See also &amp;lt;code&amp;gt;rrc&amp;lt;/code&amp;gt; which copies bit 0 to carry first&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;rti&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;pop af&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;reti&amp;lt;/code&amp;gt; || Interrupt handlers do ''not'' automatically push flags.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;rts&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ret&amp;lt;/code&amp;gt; || Can be made conditional. See also &amp;lt;code&amp;gt;jp hl&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sbc&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;sbc&amp;lt;/code&amp;gt; || Carry sense is inverted; see also &amp;lt;code&amp;gt;sub&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sec&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;scf&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sed&amp;lt;/code&amp;gt; || No direct equivalent || Use &amp;lt;code&amp;gt;daa&amp;lt;/code&amp;gt; after &amp;lt;code&amp;gt;add&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;sub&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sei&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;di&amp;lt;/code&amp;gt; || Disables vblank, as Game Boy does not use NMI &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;smb&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;set&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sta&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld [destination],a&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;stx&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld [hl], b&amp;lt;/code&amp;gt; || rowspan=&amp;quot;2&amp;quot; | There are two main ways for data to get in and out of registers: through A or through [HL].&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sty&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld [hl], c&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;stz&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;xor a&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;ld [destination],a&amp;lt;/code&amp;gt; || Sets Z, clears carry and A&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tax&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld b, a&amp;lt;/code&amp;gt; || Does not change Z&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tay&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld c, a&amp;lt;/code&amp;gt; || Does not change Z&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;trb&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;res place, [hl]&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tsb&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;set place, [hl]&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tsx&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld hl, sp+0&amp;lt;/code&amp;gt; || Does not change Z&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;txa&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld a, b&amp;lt;/code&amp;gt; || Does not change Z&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;txs&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld sp, hl&amp;lt;/code&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tya&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;ld a, c&amp;lt;/code&amp;gt; || Does not change Z&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;wai&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;halt&amp;lt;/code&amp;gt; || &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>PinoBatch</name></author>	</entry>

	</feed>