Skip to content

Commit

Permalink
Updating documentation on CPU detection
Browse files Browse the repository at this point in the history
- found an error in the opcodes: RTI takes only 6 cycles, not 7
- CPU detection debug now has better line numbering

Signed-off-by: Sven Oliver Moll <svolli@svolli.de>
  • Loading branch information
Sven Oliver Moll committed Oct 3, 2024
1 parent d4345d5 commit e10448d
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 163 deletions.
449 changes: 295 additions & 154 deletions doc/cpu_detect.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/opcodes6502.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $00;BRK;#IM;;2;7;;;1
$10;BPL;REL;;2;2;2;;2
$20;JSR;ABS;;3;6;;;1
$30;BMI;REL;;2;2;2;;2
$40;RTI;;;1;7;;;1
$40;RTI;;;1;6;;;1
$50;BVC;REL;;2;2;2;;2
$60;RTS;;;1;6;;;1
$70;BVS;REL;;2;2;2;;2
Expand Down
2 changes: 1 addition & 1 deletion doc/opcodes65816.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $00;BRK;#IM;;2;7;;;1
$10;BPL;REL;;2;2;2;;2
$20;JSR;ABS;;3;6;;;1
$30;BMI;REL;;2;2;2;;2
$40;RTI;;;1;7;;;1
$40;RTI;;;1;6;;;1
$50;BVC;REL;;2;2;2;;2
$60;RTS;;;1;6;;;1
$70;BVS;REL;;2;2;2;;2
Expand Down
2 changes: 1 addition & 1 deletion doc/opcodes65c02.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $00;BRK;#IM;;2;7;;;1
$10;BPL;REL;;2;2;2;;2
$20;JSR;ABS;;3;6;;;1
$30;BMI;REL;;2;2;2;;2
$40;RTI;;;1;7;;;1
$40;RTI;;;1;6;;;1
$50;BVC;REL;;2;2;2;;2
$60;RTS;;;1;6;;;1
$70;BVS;REL;;2;2;2;;2
Expand Down
2 changes: 1 addition & 1 deletion doc/opcodes65sc02.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $00;BRK;#IM;;2;7;;;1
$10;BPL;REL;;2;2;2;;2
$20;JSR;ABS;;3;6;;;1
$30;BMI;REL;;2;2;2;;2
$40;RTI;;;1;7;;;1
$40;RTI;;;1;6;;;1
$50;BVC;REL;;2;2;2;;2
$60;RTS;;;1;6;;;1
$70;BVS;REL;;2;2;2;;2
Expand Down
7 changes: 6 additions & 1 deletion src/rp2040/cpu_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ cputype_t cpu_detect( bool debug )
cputype = (memory[sizeof(memory)-1] < CPU_UNDEF) ? memory[sizeof(memory)-1] : CPU_ERROR;
if( debug )
{
int lineno = 0;
disass_cpu( cputype ? cputype : CPU_6502 );
disass_historian_t d = disass_historian_init( &trace[0], cycles_total, 0 );
printf( "cycles_total = %d\n", cycles_total );
Expand All @@ -114,7 +115,11 @@ cputype_t cpu_detect( bool debug )
{
break;
}
printf( "%3d:%s:%s\n", i,
if( trace[i] & bus_config.mask_reset )
{
++lineno;
}
printf( "%3d:%s:%s\n", lineno,
decode_trace( trace[i], false, 0 ),
disass_historian_entry( d, i ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/rp2040/opcodes6502.tab
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
/* $3D */ OPCODE( "AND", ABSX, 0, 3, 4, 1, 0, 0 ),
/* $3E */ OPCODE( "ROL", ABSX, 0, 3, 7, 1, 0, 0 ),
/* $3F */ OPCODE( "RLA", ABSX, 1, 3, 7, 0, 0, 0 ),
/* $40 */ OPCODE( "RTI", IMP, 0, 1, 7, 0, 0, 1 ),
/* $40 */ OPCODE( "RTI", IMP, 0, 1, 6, 0, 0, 1 ),
/* $41 */ OPCODE( "EOR", ZPIX, 0, 2, 6, 0, 0, 0 ),
/* $42 */ OPCODE( "KIL", IMP, 1, 0, 0, 0, 0, 0 ),
/* $43 */ OPCODE( "SRE", ZPIX, 1, 2, 8, 0, 0, 0 ),
Expand Down
2 changes: 1 addition & 1 deletion src/rp2040/opcodes65816.tab
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
/* $3D */ OPCODE( "AND", ABSX, 0, 3, 4, 1, 0, 0 ),
/* $3E */ OPCODE( "ROL", ABSX, 0, 3, 7, 1, 0, 0 ),
/* $3F */ OPCODE( "AND", ABSLX, 0, 4, 5, 0, 0, 0 ),
/* $40 */ OPCODE( "RTI", IMP, 0, 1, 7, 0, 0, 1 ),
/* $40 */ OPCODE( "RTI", IMP, 0, 1, 6, 0, 0, 1 ),
/* $41 */ OPCODE( "EOR", ZPIX, 0, 2, 6, 0, 0, 0 ),
/* $42 */ OPCODE( "WDM", IMM, 0, 2, 2, 0, 0, 0 ),
/* $43 */ OPCODE( "EOR", ZPS, 0, 2, 4, 0, 0, 0 ),
Expand Down
2 changes: 1 addition & 1 deletion src/rp2040/opcodes65c02.tab
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
/* $3D */ OPCODE( "AND", ABSX, 0, 3, 4, 1, 0, 0 ),
/* $3E */ OPCODE( "ROL", ABSX, 0, 3, 7, 1, 0, 0 ),
/* $3F */ OPCODE( "BBR", ZPNR, 0, 3, 5, 2, 0, 0 ),
/* $40 */ OPCODE( "RTI", IMP, 0, 1, 7, 0, 0, 1 ),
/* $40 */ OPCODE( "RTI", IMP, 0, 1, 6, 0, 0, 1 ),
/* $41 */ OPCODE( "EOR", ZPIX, 0, 2, 6, 0, 0, 0 ),
/* $42 */ OPCODE( "NOP", IMM, 1, 2, 2, 0, 0, 0 ),
/* $43 */ OPCODE( "NOP", IMP, 1, 1, 1, 0, 0, 0 ),
Expand Down
2 changes: 1 addition & 1 deletion src/rp2040/opcodes65sc02.tab
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
/* $3D */ OPCODE( "AND", ABSX, 0, 3, 4, 1, 0, 0 ),
/* $3E */ OPCODE( "ROL", ABSX, 0, 3, 7, 1, 0, 0 ),
/* $3F */ OPCODE( "NOP", IMP, 1, 1, 1, 0, 0, 0 ),
/* $40 */ OPCODE( "RTI", IMP, 0, 1, 7, 0, 0, 1 ),
/* $40 */ OPCODE( "RTI", IMP, 0, 1, 6, 0, 0, 1 ),
/* $41 */ OPCODE( "EOR", ZPIX, 0, 2, 6, 0, 0, 0 ),
/* $42 */ OPCODE( "NOP", IMM, 1, 2, 2, 0, 0, 0 ),
/* $43 */ OPCODE( "NOP", IMP, 1, 1, 1, 0, 0, 0 ),
Expand Down

0 comments on commit e10448d

Please sign in to comment.