mirror of
https://github.com/cc65/cc65.git
synced 2025-03-13 15:32:09 +00:00
[SIM65] Support undocumented opcodes for 6502
This PR is mostly a complete rewrite of the emulator for 6502/65c02 opcodes. It provides an easier to maintain implementation of the instructions, by using few macros rather than having hand-written code for each function. All undocumented, previously missing opcodes for 6502 are also implemented. The patch also includes a detailed documentation of those opcodes, for reference to developers. This PR should fix one of the milestones listed here for the next version of CC65: https://github.com/cc65/wiki/wiki/Before-the-next-release
This commit is contained in:
parent
75461e1319
commit
b04d79b1da
@ -15,7 +15,7 @@ CPU_ISET_4510 = $0400
|
||||
CPU_NONE = CPU_ISET_NONE
|
||||
CPU_6502 = CPU_ISET_6502
|
||||
CPU_6502X = CPU_ISET_6502|CPU_ISET_6502X
|
||||
CPU_6502DTV = CPU_ISET_6502|CPU_ISET_6502X|CPU_ISET_6502DTV
|
||||
CPU_6502DTV = CPU_ISET_6502|CPU_ISET_6502DTV
|
||||
CPU_65SC02 = CPU_ISET_6502|CPU_ISET_65SC02
|
||||
CPU_65C02 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02
|
||||
CPU_65816 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65816
|
||||
|
@ -9,11 +9,21 @@
|
||||
.import __MAIN_START__
|
||||
.import startup
|
||||
|
||||
.macpack cpu
|
||||
|
||||
.segment "EXEHDR"
|
||||
|
||||
.byte $73, $69, $6D, $36, $35 ; 'sim65'
|
||||
.byte 2 ; header version
|
||||
.byte .defined(__SIM65C02__) ; CPU type
|
||||
.if (.cpu .bitand ::CPU_ISET_6502X)
|
||||
.byte 2
|
||||
.elseif (.cpu .bitand ::CPU_ISET_65C02)
|
||||
.byte 1
|
||||
.elseif (.cpu .bitand ::CPU_ISET_6502)
|
||||
.byte 0
|
||||
.else
|
||||
.error Unknow CPU type.
|
||||
.endif
|
||||
.byte sp ; sp address
|
||||
.addr __MAIN_START__ ; load address
|
||||
.addr startup ; reset address
|
||||
|
2703
src/sim65/6502.c
2703
src/sim65/6502.c
File diff suppressed because it is too large
Load Diff
@ -47,7 +47,8 @@
|
||||
/* Supported CPUs */
|
||||
typedef enum CPUType {
|
||||
CPU_6502,
|
||||
CPU_65C02
|
||||
CPU_65C02,
|
||||
CPU_6502X
|
||||
} CPUType;
|
||||
|
||||
/* Current CPU */
|
||||
|
@ -177,10 +177,16 @@ static unsigned char ReadProgramFile (void)
|
||||
|
||||
/* Get the CPU type from the file header */
|
||||
if ((Val = fgetc(F)) != EOF) {
|
||||
if (Val != CPU_6502 && Val != CPU_65C02) {
|
||||
switch (Val) {
|
||||
case CPU_6502:
|
||||
case CPU_65C02:
|
||||
case CPU_6502X:
|
||||
CPU = Val;
|
||||
break;
|
||||
|
||||
default:
|
||||
Error ("'%s': Invalid CPU type", ProgramFile);
|
||||
}
|
||||
CPU = Val;
|
||||
}
|
||||
|
||||
/* Get the address of sp from the file header */
|
||||
|
Loading…
x
Reference in New Issue
Block a user