preliminary work implementing --debug-opcodes

This commit is contained in:
Gwenhael Le Moine 2024-10-08 19:22:38 +02:00
parent bb47a0d0aa
commit 1ece12bd2e
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
3 changed files with 15 additions and 6 deletions

View file

@ -1473,6 +1473,7 @@ static void ExecGroup_0( void )
Nibble n = GetNibble( cpu_status.PC++ );
debug1( CPU_CHF_MODULE_ID, DEBUG_C_TRACE, CPU_I_CALLED, "ExecGroup_0" );
debug1( CPU_CHF_MODULE_ID, DEBUG_C_OPCODES, CPU_I_EXECUTING, n );
switch ( n ) {
case 0: /* RTNSXM */
cpu_status.HST |= HST_XM_MASK;
@ -1589,6 +1590,7 @@ static void ExecGroup_1( void )
Address ta;
debug1( CPU_CHF_MODULE_ID, DEBUG_C_TRACE, CPU_I_CALLED, "ExecGroup_1" );
debug1( CPU_CHF_MODULE_ID, DEBUG_C_OPCODES, CPU_I_EXECUTING, n );
switch ( n ) {
case 0: /* Rn=A/C */
n = GetNibble( cpu_status.PC++ );
@ -2867,14 +2869,17 @@ void OneStep( void )
break;
case 2: /* P=n */
debug1( CPU_CHF_MODULE_ID, DEBUG_C_OPCODES, CPU_I_EXECUTING, n );
SetP( GetNibble( cpu_status.PC++ ) );
break;
case 3: /* LC(m) n...n */
debug1( CPU_CHF_MODULE_ID, DEBUG_C_OPCODES, CPU_I_EXECUTING, n );
FetchR( cpu_status.C, GetNibble( cpu_status.PC++ ) );
break;
case 4: /* RTNC/GOC */
debug1( CPU_CHF_MODULE_ID, DEBUG_C_OPCODES, CPU_I_EXECUTING, n );
if ( cpu_status.carry ) {
offset = Get2Nibbles2C( cpu_status.PC );
if ( offset == 0 )
@ -2887,6 +2892,7 @@ void OneStep( void )
break;
case 5: /* RTNNC/GONC */
debug1( CPU_CHF_MODULE_ID, DEBUG_C_OPCODES, CPU_I_EXECUTING, n );
if ( !cpu_status.carry ) {
offset = Get2Nibbles2C( cpu_status.PC );
if ( offset == 0 )
@ -2899,10 +2905,12 @@ void OneStep( void )
break;
case 6: /* GOTO */
debug1( CPU_CHF_MODULE_ID, DEBUG_C_OPCODES, CPU_I_EXECUTING, n );
cpu_status.PC += Get3Nibbles2C( cpu_status.PC );
break;
case 7: /* GOSUB */
debug1( CPU_CHF_MODULE_ID, DEBUG_C_OPCODES, CPU_I_EXECUTING, n );
offset = Get3Nibbles2C( cpu_status.PC );
cpu_status.PC += 3;
PushRSTK( cpu_status.PC );
@ -2942,6 +2950,7 @@ void OneStep( void )
break;
default:
debug1( CPU_CHF_MODULE_ID, DEBUG_C_OPCODES, CPU_I_EXECUTING, n );
ChfGenerate( CPU_CHF_MODULE_ID, __FILE__, __LINE__, CPU_E_BAD_OPCODE, CHF_ERROR, cpu_status.PC, n );
ChfSignal( CPU_CHF_MODULE_ID );
break;

View file

@ -134,7 +134,7 @@
#define DEBUG_C_FLASH 0x0080 /* 3.3: Flash ROM */
#define DEBUG_C_X_FUNC 0x0040 /* 3.13: Extended functions */
#define DEBUG_C_REVISION 0x0010 /* Revision information */
// #define DEBUG_C_X11 0x0001 /* X11 Interface */
#define DEBUG_C_OPCODES 0x0001 /* OpCodes */
#define DEBUG_C_NONE 0
/*---------------------------------------------------------------------------

View file

@ -183,7 +183,7 @@ config_t* config_init( int argc, char* argv[] )
{"mono", no_argument, &clopt_mono, true },
{"gray", no_argument, &clopt_gray, true },
/* {"debug-x11", no_argument, NULL, 38601 }, */
{"debug-opcodes", no_argument, NULL, 38601 },
{"debug-revision", no_argument, NULL, 38602 },
{"debug-x-func", no_argument, NULL, 38603 },
{"debug-flash", no_argument, NULL, 38604 },
@ -232,7 +232,7 @@ config_t* config_init( int argc, char* argv[] )
"false)\n"
" --reset force a reset\n"
" --monitor start with monitor\n"
/* " --debug-x11 enables debugging x11 (default: no)\n" */
" --debug-opcodes enables debugging opcodes (default: no)\n"
" --debug-revision enables debugging revision (default: no)\n"
" --debug-x-func enables debugging extended functions (default: no)\n"
" --debug-flash enables debugging flash (default: no)\n"
@ -289,9 +289,9 @@ config_t* config_init( int argc, char* argv[] )
/* clopt_port_2_file_name = optarg; */
/* break; */
/* case 38601: */
/* config.debug_level |= DEBUG_C_X11; */
/* break; */
case 38601:
config.debug_level |= DEBUG_C_OPCODES;
break;
case 38602:
config.debug_level |= DEBUG_C_REVISION;
break;