We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

Emulation Mode Flag: Difference between revisions

From SnesLab
Jump to: navigation, search
(SP's high byte is 1)
(opcode matrix note)
Line 11: Line 11:
The flag is set when a [[RESET]] interrupt is fired. In other words, the CPU always starts in emulation mode at boot and after a reset.
The flag is set when a [[RESET]] interrupt is fired. In other words, the CPU always starts in emulation mode at boot and after a reset.


The 65c816 does not attempt to emulate the illegal 6502 opcodes.
The 65c816 does not attempt to emulate the illegal 6502 opcodes because its [[65c816 Opcode Matrix|opcode matrix]] is already full.


For writing new SNES code it is recommended to always stay in native mode even if dealing with 8 bit data.  One reason is page boundary crossings incur a one cycle penalty in emulation mode.  Emulation mode emulates the NMOS 6502 cycle counts.
For writing new SNES code it is recommended to always stay in native mode even if dealing with 8 bit data.  One reason is page boundary crossings incur a one cycle penalty in emulation mode.  Emulation mode emulates the NMOS 6502 cycle counts.

Revision as of 22:06, 31 July 2024

The Emulation Mode Flag (E) controls whether the 65c816 is behaving like a 6502.

When clear, the MPU is in 65c816 native mode.

When set, the MPU is in 6502 emulation mode.

This flag cannot be modified directly and is normally hidden from the programmer. To modify it, use the XCE instruction to swap its value with the carry flag's value. This treats the status register bits as a game of musical chairs.

The designers likely omitted CLE and SEE opcodes to set or clear it directly because dedicating two opcodes to such a rare operation is overkill.

The flag is set when a RESET interrupt is fired. In other words, the CPU always starts in emulation mode at boot and after a reset.

The 65c816 does not attempt to emulate the illegal 6502 opcodes because its opcode matrix is already full.

For writing new SNES code it is recommended to always stay in native mode even if dealing with 8 bit data. One reason is page boundary crossings incur a one cycle penalty in emulation mode. Emulation mode emulates the NMOS 6502 cycle counts.

Emulation code need not be in bank 0.

In emulation mode, the stack pointer's high byte is always one.

References