mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-11 14:30:08 +00:00
Enable illegal BCD break/debugging
* Debugging builds will now segfault if an illegal BCD is encountered * Presumably current x86 undefined behavior does not 100% correspond to 6502 undefined behavior ... (this bears further investigation)
This commit is contained in:
parent
6724e06500
commit
43ada45a36
@ -343,8 +343,35 @@
|
||||
adcb %al, A_Reg; \
|
||||
FlagNVZC
|
||||
|
||||
// REFACTOR:
|
||||
#ifndef NDEBUG
|
||||
#define DebugBCDCheck \
|
||||
testb $0x80, A_Reg; \
|
||||
jz 6f; \
|
||||
testb $0x60, A_Reg; \
|
||||
jz 6f; \
|
||||
call SN(c_debug_illegal_bcd); \
|
||||
6: testb $0x08, A_Reg; \
|
||||
jz 7f; \
|
||||
testb $0x06, A_Reg; \
|
||||
jz 7f; \
|
||||
call SN(c_debug_illegal_bcd); \
|
||||
7: testb $0x80, %al; \
|
||||
jz 8f; \
|
||||
testb $0x60, %al; \
|
||||
jz 8f; \
|
||||
call SN(c_debug_illegal_bcd); \
|
||||
8: testb $0x08, %al; \
|
||||
jz 9f; \
|
||||
testb $0x06, %al; \
|
||||
jz 9f; \
|
||||
call SN(c_debug_illegal_bcd); \
|
||||
9:
|
||||
#else
|
||||
#define DebugBCDCheck
|
||||
#endif
|
||||
|
||||
#define DoADC_d GetFromEA_B \
|
||||
DebugBCDCheck \
|
||||
bt $C_Flag_Bit, FF_Reg; \
|
||||
adcb A_Reg, %al; \
|
||||
daa; \
|
||||
@ -445,6 +472,7 @@
|
||||
FlagNVZC
|
||||
|
||||
#define DoSBC_d GetFromEA_B \
|
||||
DebugBCDCheck \
|
||||
bt $C_Flag_Bit, FF_Reg; \
|
||||
cmc; \
|
||||
xchgb A_Reg, %al; \
|
||||
@ -1619,6 +1647,7 @@ op_RTS:
|
||||
|
||||
/* ----------------------------------
|
||||
SBC instructions
|
||||
SuBtract memory from accumulator with Borrow
|
||||
---------------------------------- */
|
||||
|
||||
op_SBC_dec:
|
||||
|
11
src/misc.c
11
src/misc.c
@ -76,6 +76,17 @@ void *base_c5rom;
|
||||
uint8_t *base_cxrom;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
c_debug_illegal_bcd - illegal BCD (decimal mode) computation
|
||||
------------------------------------------------------------------------- */
|
||||
void c_debug_illegal_bcd()
|
||||
{
|
||||
ERRLOG("Illegal/undefined BCD operation encountered, debug break on c_debug_illegal_bcd to debug...");
|
||||
char *ptr = (char*)0x0bad;
|
||||
*ptr = 0x1337; // segfault
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
c_set_altchar() - set alternate character set
|
||||
------------------------------------------------------------------------- */
|
||||
|
Loading…
x
Reference in New Issue
Block a user