fetch & fetch16 and other debugger related improvements

This commit is contained in:
tudnai 2022-10-28 05:10:07 -07:00
parent 0ab06b0a80
commit 783c5602bc
10 changed files with 187 additions and 182 deletions

View File

@ -1979,7 +1979,6 @@
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 0.85;
OTHER_CFLAGS = (
"-D_NO_DEBUGGER",
"-D_NO_DISASSEMBLER",
"-D_NO_INTERRUPT_CHECK_PER_STEP",
"-D_NO_CLK_ABSOLUTE_PRECISE",
@ -2023,8 +2022,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 0.85;
OTHER_CFLAGS = (
"-D_NO_DEBUGGER",
"-D_NO_DISASSEMBLER",
"-DDISASSEMBLER",
"-D_NO_INTERRUPT_CHECK_PER_STEP",
"-D_NO_CLK_ABSOLUTE_PRECISE",
);

View File

@ -48,7 +48,7 @@
value = "default_MHz_6502 * 1000 * 1000 / spkr_sample_rate">
</PersistentString>
<PersistentString
value = "( (spkr_clk + m6502.clkfrm) / ( 1024000 / spkr_sample_rate ) ) * 2">
value = "( (spkr_clk + m6502.clkfrm) / ( default_MHz_6502 * 1000 * 1000 / spkr_sample_rate)) * 2">
</PersistentString>
<PersistentString
value = "(int16_t)28000 + (int16_t)-32768">
@ -66,7 +66,7 @@
value = "(spkr_clk + m6502.clkfrm)">
</PersistentString>
<PersistentString
value = "( (spkr_clk + m6502.clkfrm) / ( default_MHz_6502 * 1000 * 1000 / spkr_sample_rate)) * 2">
value = "( (spkr_clk + m6502.clkfrm) / ( 1024000 / spkr_sample_rate ) ) * 2">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -158,7 +158,7 @@
contextName = "closure #1 in ViewController.Update():ViewController.swift">
<PersistentStrings>
<PersistentString
value = "txtArr">
value = "MEMcfg.is_80STORE">
</PersistentString>
<PersistentString
value = "self.shadowTxt">
@ -170,7 +170,7 @@
value = "MEMcfg.txt_page_2">
</PersistentString>
<PersistentString
value = "MEMcfg.is_80STORE">
value = "txtArr">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -197,7 +197,7 @@
contextName = "ViewController.Update():ViewController.swift">
<PersistentStrings>
<PersistentString
value = "spkr_play_disk_motor_time">
value = "cpuState">
</PersistentString>
<PersistentString
value = "mouseLocation">
@ -209,10 +209,10 @@
value = "txtArr">
</PersistentString>
<PersistentString
value = "Disk1_ButtonCell.image">
value = "textCols">
</PersistentString>
<PersistentString
value = "textCols">
value = "Disk1_ButtonCell.image">
</PersistentString>
<PersistentString
value = "textLines">
@ -233,7 +233,7 @@
value = "frameCounter">
</PersistentString>
<PersistentString
value = "cpuState">
value = "spkr_play_disk_motor_time">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -299,7 +299,7 @@
contextName = "LoRes.Update():LoRes.swift">
<PersistentStrings>
<PersistentString
value = "blockChanged[ screenIdx ]">
value = "UInt8( (block &gt;&gt; 4) &amp; 0x0F )">
</PersistentString>
<PersistentString
value = "UInt8(block)">
@ -308,7 +308,7 @@
value = "UInt8(block &amp; 4)">
</PersistentString>
<PersistentString
value = "UInt8( (block &gt;&gt; 4) &amp; 0x0F )">
value = "blockChanged[ screenIdx ]">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -561,10 +561,10 @@
contextName = "ToolBarController.GamePort(_:):ToolBarController.swift">
<PersistentStrings>
<PersistentString
value = "ViewController.current?.mouseCursorJoystickEmulation">
value = "ViewController.current?.mouseCursorHidden">
</PersistentString>
<PersistentString
value = "ViewController.current?.mouseCursorHidden">
value = "ViewController.current?.mouseCursorJoystickEmulation">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -603,13 +603,21 @@
contextName = "HiRes.compute():HiRes.swift">
<PersistentStrings>
<PersistentString
value = "computePipelineState.maxTotalThreadsPerThreadgroup">
value = "UnsafeRawBufferPointer(result)">
</PersistentString>
<PersistentString
value = "result[2]">
</PersistentString>
<PersistentString
value = "UnsafeRawBufferPointer(result)">
value = "computePipelineState.maxTotalThreadsPerThreadgroup">
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName = "DebuggerViewController.DisplayDisassembly():DebuggerViewController.swift">
<PersistentStrings>
<PersistentString
value = "m6502.PC">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -668,7 +676,7 @@
value = "new">
</PersistentString>
<PersistentString
value = "WOZwrite.shift16">
value = "WOZtmp.shift16">
</PersistentString>
<PersistentString
value = "WOZwrite.shift">
@ -680,7 +688,7 @@
value = "(1 &lt;&lt; i) - 1">
</PersistentString>
<PersistentString
value = "WOZtmp.shift16">
value = "WOZwrite.shift16">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -776,6 +784,9 @@
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName = "disassemblyLine:disassembler.c">
</ContextState>
<ContextState
contextName = "POP:6502_instr_stack.h">
</ContextState>
@ -829,10 +840,10 @@
contextName = "set_flags_NZC:common.h">
<PersistentStrings>
<PersistentString
value = "(unsigned)test ">
value = "(unsigned)0xFF">
</PersistentString>
<PersistentString
value = "(unsigned)0xFF">
value = "(unsigned)test ">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -866,14 +877,17 @@
contextName = "HiRes.draw(_:):HiRes.swift">
<PersistentStrings>
<PersistentString
value = "linAddr">
value = "shadowScreen">
</PersistentString>
<PersistentString
value = "ctx?.height">
value = "ctx?.data">
</PersistentString>
<PersistentString
value = "ctx?.width">
</PersistentString>
<PersistentString
value = "ctx?.bitmapInfo">
</PersistentString>
<PersistentString
value = "ctx?.bytesPerRow">
</PersistentString>
@ -883,24 +897,21 @@
<PersistentString
value = "HiResLineAddrTbl">
</PersistentString>
<PersistentString
value = "ctx?.bitmapInfo">
</PersistentString>
<PersistentString
value = "(blockH7 | ( block &amp; bitMask ))">
</PersistentString>
<PersistentString
value = "HiRes.blockCols">
</PersistentString>
<PersistentString
value = "ctx?.height">
</PersistentString>
<PersistentString
value = "linAddr">
</PersistentString>
<PersistentString
value = "ctx?.bitsPerComponent">
</PersistentString>
<PersistentString
value = "shadowScreen">
</PersistentString>
<PersistentString
value = "ctx?.data">
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
@ -935,10 +946,10 @@
value = "m6502">
</PersistentString>
<PersistentString
value = "Apple2_64K_RAM + 0x3600">
value = "m6502.PC">
</PersistentString>
<PersistentString
value = "(void*)Apple2_64K_RAM">
value = "m6502.clkfrm">
</PersistentString>
<PersistentString
value = "m6502.ecoSpindown">
@ -947,10 +958,10 @@
value = "Apple2_64K_AUX + 0x3600">
</PersistentString>
<PersistentString
value = "m6502.PC">
value = "(void*)Apple2_64K_RAM">
</PersistentString>
<PersistentString
value = "m6502.clkfrm">
value = "Apple2_64K_RAM + 0x3600">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -969,7 +980,7 @@
value = "textDisplay_height_diff">
</PersistentString>
<PersistentString
value = "textDisplay.frame">
value = "textDisplay_width_diff">
</PersistentString>
<PersistentString
value = "MonitorView.textViewBounds">
@ -981,7 +992,7 @@
value = "textDisplay.bounds">
</PersistentString>
<PersistentString
value = "textDisplay_width_diff">
value = "textDisplay.frame">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -1080,7 +1091,7 @@
value = "pdl_value[pdl]">
</PersistentString>
<PersistentString
value = "normalized_time &gt;= pdl_value[pdl] ? 255 : 0">
value = "normalized_time">
</PersistentString>
<PersistentString
value = "(3300 * 255/3300)">
@ -1092,7 +1103,7 @@
value = "1 * 512 * (1 - ( 3300 / 3300.0 ))">
</PersistentString>
<PersistentString
value = "normalized_time">
value = "normalized_time &gt;= pdl_value[pdl] ? 255 : 0">
</PersistentString>
</PersistentStrings>
</ContextState>
@ -1163,10 +1174,10 @@
value = "Apple2_64K_AUX + 0xC600">
</PersistentString>
<PersistentString
value = "(void*)rom">
value = "Apple2_64K_RAM + 0xC600">
</PersistentString>
<PersistentString
value = "Apple2_64K_RAM + 0xC600">
value = "(void*)rom">
</PersistentString>
<PersistentString
value = "strlen(fullPath)">

View File

@ -493,7 +493,7 @@ void rom_loadFile( const char * bundlePath, const char * filename ) {
void openLog() {
#ifdef DISASSEMBLER
#ifdef DISASSEMBLER_LOG
outdev = fopen("/Users/trudnai/Library/Containers/com.trudnai.steveii/Data/disassembly_new.log", "w+");
#endif
// for DEBUG ONLY!!! -- use stdout if could not create log file

View File

@ -24,7 +24,9 @@
#ifndef __6502_INSTR_BRANCH_H__
#define __6502_INSTR_BRANCH_H__
INLINE void BRA( int8_t reladdr ) {
#ifndef DEBUGGER
INSTR void _BRA( int8_t reladdr ) {
uint8_t pg = m6502.PC >> 8;
m6502.PC += reladdr;
m6502.clkfrm += m6502.PC >> 8 == pg ? 1 : 2;
@ -36,6 +38,25 @@ INLINE void BRA( int8_t reladdr ) {
#endif
dbgPrintf("BRA %04X ", m6502.PC);
}
#endif // DEBUGGER
/**
BRA Branch Unconditionally
addressing assembler opc bytes cyles
--------------------------------------------
relative BRA oper 90 2 2**
**/
INSTR void BRA( int8_t reladdr ) {
dbgPrintf("BRA ");
disPrintf(disassembly.inst, "BRA");
#ifndef DEBUGGER
_BRA( reladdr );
#endif
}
/**
BCC Branch on Carry Clear
@ -47,13 +68,13 @@ INLINE void BRA( int8_t reladdr ) {
--------------------------------------------
relative BCC oper 90 2 2**
**/
INLINE void BCC( int8_t reladdr ) {
INSTR void BCC( int8_t reladdr ) {
dbgPrintf("BCC ");
disPrintf(disassembly.inst, "BCC");
#ifndef DEBUGGER
if ( ! m6502.C ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -71,13 +92,13 @@ INLINE void BCC( int8_t reladdr ) {
--------------------------------------------
relative BCS oper B0 2 2**
**/
INLINE void BCS( int8_t reladdr ) {
INSTR void BCS( int8_t reladdr ) {
dbgPrintf("BCS ");
disPrintf(disassembly.inst, "BCS");
#ifndef DEBUGGER
if ( m6502.C ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -95,13 +116,13 @@ INLINE void BCS( int8_t reladdr ) {
--------------------------------------------
relative BNE oper D0 2 2**
**/
INLINE void BNE( int8_t reladdr ) {
INSTR void BNE( int8_t reladdr ) {
dbgPrintf("BNE ");
disPrintf(disassembly.inst, "BNE");
#ifndef DEBUGGER
if ( ! m6502.Z ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -119,13 +140,13 @@ INLINE void BNE( int8_t reladdr ) {
--------------------------------------------
relative BEQ oper F0 2 2**
**/
INLINE void BEQ( int8_t reladdr ) {
INSTR void BEQ( int8_t reladdr ) {
dbgPrintf("BEQ ");
disPrintf(disassembly.inst, "BEQ");
#ifndef DEBUGGER
if ( m6502.Z ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -143,13 +164,13 @@ INLINE void BEQ( int8_t reladdr ) {
--------------------------------------------
relative BPL oper 10 2 2**
**/
INLINE void BPL( int8_t reladdr ) {
INSTR void BPL( int8_t reladdr ) {
dbgPrintf("BPL ");
disPrintf(disassembly.inst, "BPL");
#ifndef DEBUGGER
if ( ! m6502.N ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -167,13 +188,13 @@ INLINE void BPL( int8_t reladdr ) {
--------------------------------------------
relative BMI oper 30 2 2**
**/
INLINE void BMI( int8_t reladdr ) {
INSTR void BMI( int8_t reladdr ) {
dbgPrintf("BMI ");
disPrintf(disassembly.inst, "BMI");
#ifndef DEBUGGER
if ( m6502.N ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -191,13 +212,13 @@ INLINE void BMI( int8_t reladdr ) {
--------------------------------------------
relative BVC oper 50 2 2**
**/
INLINE void BVC( int8_t reladdr ) {
INSTR void BVC( int8_t reladdr ) {
dbgPrintf("BVC ");
disPrintf(disassembly.inst, "BVC");
#ifndef DEBUGGER
if ( ! m6502.V ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -215,13 +236,13 @@ INLINE void BVC( int8_t reladdr ) {
--------------------------------------------
relative BVC oper 70 2 2**
**/
INLINE void BVS( int8_t reladdr ) {
INSTR void BVS( int8_t reladdr ) {
dbgPrintf("BVS ");
disPrintf(disassembly.inst, "BVS");
#ifndef DEBUGGER
if ( m6502.V ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -271,15 +292,15 @@ INLINE void BVS( int8_t reladdr ) {
**/
#ifndef DEBUGGER
#define BBR(n) INLINE void BBR##n( uint8_t src, int8_t reladdr ) { \
#define BBR(n) INSTR void BBR##n( uint8_t src, int8_t reladdr ) { \
dbgPrintf("BBR"#n" "); \
disPrintf(disassembly.inst, "BBR"#n); \
if ( ! (src & (1 << n) ) ) { \
BRA( reladdr ); \
_BRA( reladdr ); \
} \
}
#else
#define BBR(n) INLINE void BBR##n( uint8_t src, int8_t reladdr ) { \
#define BBR(n) INSTR void BBR##n( uint8_t src, int8_t reladdr ) { \
dbgPrintf("BBR"#n" "); \
disPrintf(disassembly.inst, "BBR"#n); \
}
@ -296,15 +317,15 @@ disPrintf(disassembly.inst, "BBR"#n); \
#ifndef DEBUGGER
#define BBS(n) INLINE void BBS##n( uint8_t src, int8_t reladdr ) { \
#define BBS(n) INSTR void BBS##n( uint8_t src, int8_t reladdr ) { \
dbgPrintf("BBS"#n" "); \
disPrintf(disassembly.inst, "BBS"#n); \
if ( (src & (1 << n) ) ) { \
BRA( reladdr ); \
_BRA( reladdr ); \
} \
}
#else
#define BBS(n) INLINE void BBS##n( uint8_t src, int8_t reladdr ) { \
#define BBS(n) INSTR void BBS##n( uint8_t src, int8_t reladdr ) { \
dbgPrintf("BBS"#n" "); \
disPrintf(disassembly.inst, "BBS"#n); \
}

View File

@ -24,11 +24,12 @@
#ifndef __6502_INSTR_BRANCH_H__
#define __6502_INSTR_BRANCH_H__
INSTR void BRA( int8_t reladdr ) {
#ifndef DEBUGGER
INSTR void _BRA( int8_t reladdr ) {
uint8_t pg = m6502.PC >> 8;
m6502.PC += reladdr;
m6502.clkfrm += m6502.PC >> 8 == pg ? 1 : 2;
#ifdef DEBUG
if ( reladdr == -2 ) {
dbgPrintf2("Infinite Loop at %04X!\n", m6502.PC);
@ -36,6 +37,25 @@ INSTR void BRA( int8_t reladdr ) {
#endif
dbgPrintf("BRA %04X ", m6502.PC);
}
#endif // DEBUGGER
/**
BRA Branch Unconditionally
addressing assembler opc bytes cyles
--------------------------------------------
relative BRA oper 90 2 2**
**/
INSTR void BRA( int8_t reladdr ) {
dbgPrintf("BRA ");
disPrintf(disassembly.inst, "BRA");
#ifndef DEBUGGER
_BRA( reladdr );
#endif
}
/**
BCC Branch on Carry Clear
@ -53,7 +73,7 @@ INSTR void BCC( int8_t reladdr ) {
#ifndef DEBUGGER
if ( ! m6502.C ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -77,7 +97,7 @@ INSTR void BCS( int8_t reladdr ) {
#ifndef DEBUGGER
if ( m6502.C ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -101,7 +121,7 @@ INSTR void BNE( int8_t reladdr ) {
#ifndef DEBUGGER
if ( ! m6502.Z ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -125,7 +145,7 @@ INSTR void BEQ( int8_t reladdr ) {
#ifndef DEBUGGER
if ( m6502.Z ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -149,7 +169,7 @@ INSTR void BPL( int8_t reladdr ) {
#ifndef DEBUGGER
if ( ! m6502.N ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -173,7 +193,7 @@ INSTR void BMI( int8_t reladdr ) {
#ifndef DEBUGGER
if ( m6502.N ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -197,7 +217,7 @@ INSTR void BVC( int8_t reladdr ) {
#ifndef DEBUGGER
if ( ! m6502.V ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -221,7 +241,7 @@ INSTR void BVS( int8_t reladdr ) {
#ifndef DEBUGGER
if ( m6502.V ) {
BRA( reladdr );
_BRA( reladdr );
}
else {
dbgPrintf("-no-");
@ -275,7 +295,7 @@ INSTR void BVS( int8_t reladdr ) {
dbgPrintf("BBR"#n" "); \
disPrintf(disassembly.inst, "BBR"#n); \
if ( ! (src & (1 << n) ) ) { \
BRA( reladdr ); \
_BRA( reladdr ); \
} \
}
#else
@ -300,7 +320,7 @@ disPrintf(disassembly.inst, "BBR"#n); \
dbgPrintf("BBS"#n" "); \
disPrintf(disassembly.inst, "BBS"#n); \
if ( (src & (1 << n) ) ) { \
BRA( reladdr ); \
_BRA( reladdr ); \
} \
}
#else

View File

@ -70,7 +70,7 @@ void CALL( uint16_t addr ) {
void JUMP( uint16_t addr ) {
dbgPrintf("JUMP ");
disPrintf(disassembly.inst, "JUMP");
m6502.PC = addr;
}

View File

@ -403,7 +403,6 @@ INLINE uint8_t kbdStrobe(void) {
}
#ifndef DEBUGGER
INLINE uint8_t ioRead( uint16_t addr ) {
// if (outdev) fprintf(outdev, "ioRead:%04X\n", addr);
@ -950,7 +949,6 @@ INLINE void ioWrite( uint16_t addr, uint8_t val ) {
}
return;
}
#endif
/**
Naive implementation of RAM read from address
@ -962,11 +960,9 @@ INLINE uint8_t memread8_high( uint16_t addr ) {
return RDHIMEM[addr];
}
INLINE uint8_t memread8( uint16_t addr ) {
#ifndef DEBUGGER
if (addr >= 0xC000) {
return memread8_high(addr);
}
#endif
return memread8_low(addr);
}
/**
@ -988,7 +984,6 @@ INLINE uint16_t memread16( uint16_t addr ) {
}
INLINE uint8_t memread( uint16_t addr ) {
#ifndef DEBUGGER
if (addr >= 0xC000) {
if (addr < 0xC100) {
return ioRead(addr);
@ -997,7 +992,6 @@ INLINE uint8_t memread( uint16_t addr ) {
// return memread8_paged(addr);
return memread8_high(addr);
}
#endif
// return memread8_paged(addr);
return memread8_low(addr);
@ -1026,22 +1020,15 @@ INLINE uint8_t memread( uint16_t addr ) {
**/
INLINE void memwrite8_low( uint16_t addr, uint8_t data ) {
#ifndef DEBUGGER
WRLOMEM[addr] = data;
#endif
}
INLINE void memwrite8_bank( uint16_t addr, uint8_t data ) {
#ifndef DEBUGGER
WRD0MEM[addr] = data;
#endif
}
INLINE void memwrite8_high( uint16_t addr, uint8_t data ) {
#ifndef DEBUGGER
WRHIMEM[addr] = data;
#endif
}
INLINE void memwrite( uint16_t addr, uint8_t data ) {
#ifndef DEBUGGER
if (addr >= 0xC000) {
if (addr < 0xC100) {
ioWrite(addr, data);
@ -1063,15 +1050,14 @@ INLINE void memwrite( uint16_t addr, uint8_t data ) {
// RAM
memwrite8_low(addr, data);
}
#endif
}
/**
Fetching 1 byte from memory address pc (program counter)
increase pc by one
**/
INLINE uint8_t fetch() {
disHexB( disassembly.pOpcode, memread(m6502.PC) );
INLINE uint8_t _fetch() {
disHexB( disassembly.pOpcode, memread8_low(m6502.PC) );
#ifdef CLK_ABSOLUTE_PRECISE
if ( (m6502.PC & 0xFF) >= 0xFF ) {
m6502.clktime++;
@ -1080,11 +1066,16 @@ INLINE uint8_t fetch() {
return memread8_low( m6502.PC++ );
}
INLINE uint8_t _fetch_dbg() {
_disHexB( &disassembly.pOpcode, memread8_low(m6502.PC) );
return memread8_low( m6502.PC++ );
}
/**
Fetching 2 bytes as a 16 bit number from memory address pc (program counter)
increase pc by one
**/
INLINE uint16_t fetch16() {
INLINE uint16_t _fetch16() {
uint16_t word = memread16( m6502.PC );
// disPrintf(disassembly.comment, "fetch16:%04X", word);
#ifdef CLK_ABSOLUTE_PRECISE
@ -1102,6 +1093,17 @@ INLINE uint16_t fetch16() {
return word;
}
INLINE uint16_t _fetch16_dbg() {
uint16_t word = memread16( m6502.PC );
// disPrintf(disassembly.comment, "fetch16:%04X", word);
m6502.PC += 2;
_disHexB( &disassembly.pOpcode, (uint8_t)word );
_disHexB( &disassembly.pOpcode, (uint8_t)(word >> 8));
return word;
}
@ -1120,11 +1122,7 @@ INLINE uint16_t addr_abs() {
return fetch16();
}
INLINE uint8_t src_abs() {
#ifndef DEBUGGER
return memread( addr_abs() );
#else
return 0;
#endif
}
//INLINE uint8_t * dest_abs() {
// return WRLOMEM + addr_abs();
@ -1143,11 +1141,7 @@ INLINE uint16_t ind_addr() {
disPrintf(disassembly.oper, "($%04X)", memread16(m6502.PC));
disPrintf(disassembly.comment, "ind_addr:%04X", memread16(memread16(m6502.PC)));
#ifndef DEBUGGER
return memread16( fetch16() );
#else
return 0;
#endif
}
/**
@ -1160,11 +1154,7 @@ INLINE uint16_t addr_abs_X() {
return fetch16() + m6502.X;
}
INLINE uint8_t src_abs_X() {
#ifndef DEBUGGER
return memread( addr_abs_X() );
#else
return 0;
#endif
}
//INLINE uint8_t * dest_abs_X() {
// return WRLOMEM + addr_abs_X();
@ -1181,11 +1171,7 @@ INLINE uint16_t addr_abs_Y() {
return fetch16() + m6502.Y;
}
INLINE uint8_t src_abs_Y() {
#ifndef DEBUGGER
return memread(addr_abs_Y());
#else
return 0;
#endif
}
//INLINE uint8_t * dest_abs_Y() {
// return WRLOMEM + addr_abs_Y();
@ -1207,11 +1193,7 @@ INLINE uint8_t addr_zp() {
return fetch();
}
INLINE uint8_t src_zp() {
#ifndef DEBUGGER
return memread8_low(addr_zp());
#else
return 0;
#endif
}
//INLINE uint8_t * dest_zp() {
// return WRLOMEM + addr_zp();
@ -1237,18 +1219,10 @@ INLINE uint16_t addr_ind() {
disPrintf(disassembly.oper, "($%02X,X)", memread8(m6502.PC) );
disPrintf(disassembly.comment, "ind_addr:%04X", memread16( memread8(m6502.PC)) );
#ifndef DEBUGGER
return memread16( fetch() );
#else
return 0;
#endif
}
INLINE uint8_t src_ind() {
#ifndef DEBUGGER
return memread( addr_ind() );
#else
return 0;
#endif
}
/**
@ -1261,18 +1235,10 @@ INLINE uint16_t addr_ind_X() {
disPrintf(disassembly.oper, "($%02X,X)", memread8(m6502.PC) );
disPrintf(disassembly.comment, "ind_addr:%04X", memread16( memread8(m6502.PC) + m6502.X) );
#ifndef DEBUGGER
return memread16( fetch() + m6502.X );
#else
return 0;
#endif
}
INLINE uint8_t src_X_ind() {
#ifndef DEBUGGER
return memread( addr_ind_X() );
#else
return 0;
#endif
}
//INLINE uint8_t * dest_X_ind() {
// return WRLOMEM + addr_ind_X();
@ -1289,18 +1255,10 @@ INLINE uint16_t addr_ind_Y() {
disPrintf(disassembly.oper, "($%02X),Y", memread8(m6502.PC) );
disPrintf(disassembly.comment, "ind_addr:%04X", memread16( memread8(m6502.PC) ) + m6502.Y );
#ifndef DEBUGGER
return memread16( fetch() ) + m6502.Y;
#else
return 0;
#endif
}
INLINE uint8_t src_ind_Y() {
#ifndef DEBUGGER
return memread( addr_ind_Y() );
#else
return 0;
#endif
}
//INLINE uint8_t * dest_ind_Y() {
// return WRLOMEM + addr_ind_Y();
@ -1315,18 +1273,10 @@ INLINE uint8_t src_ind_Y() {
INLINE uint8_t addr_zp_X() {
disPrintf(disassembly.oper, "$%02X,X", memread8(m6502.PC));
#ifndef DEBUGGER
return fetch() + m6502.X;
#else
return 0;
#endif
}
INLINE uint8_t src_zp_X() {
#ifndef DEBUGGER
return memread8_low(addr_zp_X());
#else
return 0;
#endif
}
//INLINE uint8_t * dest_zp_X() {
// return WRLOMEM + addr_zp_X();
@ -1340,25 +1290,16 @@ INLINE uint8_t src_zp_X() {
INLINE uint8_t addr_zp_Y() {
disPrintf(disassembly.oper, "$%02X,Y", memread8(m6502.PC));
#ifndef DEBUGGER
return fetch() + m6502.Y;
#else
return 0;
#endif
}
INLINE uint8_t src_zp_Y() {
#ifndef DEBUGGER
return memread8_low(addr_zp_Y());
#else
return 0;
#endif
}
//INLINE uint8_t * dest_zp_Y() {
// return WRLOMEM + addr_zp_Y();
//}
#ifndef DEBUGGER
void auxMemorySelect( MEMcfg_t newMEMcfg ) {
const uint8_t * newReadMEM = currentLowRDMEM;
uint8_t * newWriteMEM = currentLowWRMEM;
@ -1647,7 +1588,6 @@ void kbdUp () {
Apple2_64K_RAM[io_KBDSTRB] &= 0x7F;
}
#endif

View File

@ -24,6 +24,8 @@
#ifndef __APPLE2_MMIO_H__
#define __APPLE2_MMIO_H__
#pragma message("MMIO")
#include <string.h>
#include "common.h"
@ -412,8 +414,10 @@ INLINE void memwrite8_low( uint16_t addr, uint8_t data );
INLINE void memwrite8_bank( uint16_t addr, uint8_t data );
INLINE void memwrite8_high( uint16_t addr, uint8_t data );
INLINE void memwrite( uint16_t addr, uint8_t data );
INLINE uint8_t fetch(void);
INLINE uint16_t fetch16(void);
INLINE uint8_t _fetch(void);
INLINE uint8_t _fetch_dbg(void);
INLINE uint16_t _fetch16(void);
INLINE uint16_t _fetch16_dbg(void);
INLINE uint16_t addr_abs(void);
INLINE uint8_t src_abs(void);
INLINE int8_t rel_addr(void);
@ -438,5 +442,18 @@ INLINE uint8_t addr_zp_Y(void);
INLINE uint8_t src_zp_Y(void);
#ifndef DEBUGGER
#define fetch() _fetch()
#define fetch16() _fetch16()
#else // DEBUGGER
#define fetch() _fetch_dbg()
#define fetch16() _fetch16_dbg()
#endif // DEBUGGER
#endif // __APPLE2_MMIO_H__

View File

@ -10,6 +10,7 @@
#include <string.h>
#include <stdarg.h>
#include "disassembler.h"
#include "6502.h"
disassembly_t disassembly;
unsigned long long discnt = 0;
@ -31,38 +32,38 @@ INLINE flags_t getFlags2(void) {
void _disHexB( char ** s, const uint8_t b ) {
if ( m6502.dbgLevel.trace ) {
// if ( m6502.dbgLevel.trace ) {
snprintf(*s, 4, "%02X ", b);
*s += 3;
}
// }
}
void _disHexW( char ** s, const uint16_t w ) {
if ( m6502.dbgLevel.trace ) {
// if ( m6502.dbgLevel.trace ) {
snprintf(*s, 6, "%04X ", w);
*s += 5;
}
// }
}
void _disPuts( char ** s, const char * from ) {
if ( m6502.dbgLevel.trace ) {
// if ( m6502.dbgLevel.trace ) {
while ( (*(*s)++ = *from++) );
}
// }
}
void _disPrintf( char * s, const size_t n, const char * fmt, ... ) {
if ( m6502.dbgLevel.trace ) {
// if ( m6502.dbgLevel.trace ) {
va_list arg_ptr;
va_start(arg_ptr, fmt);
vsnprintf( s, n, fmt, arg_ptr );
va_end(arg_ptr);
}
// }
}
void _disNewInstruction(void) {
if ( m6502.dbgLevel.trace ) {
// if ( m6502.dbgLevel.trace ) {
memset( &disassembly, 0, sizeof(disassembly) );
disassembly.clk = m6502.clktime + m6502.clkfrm;
snprintf(disassembly.addr, 5, "%04X ", m6502.PC);
@ -71,7 +72,7 @@ void _disNewInstruction(void) {
// disassembly.inst[0] = '\0';
// disassembly.oper[0] = '\0';
// disassembly.comment[0] = '\0';
}
// }
}

View File

@ -24,7 +24,7 @@
#ifndef disassembler_h
#define disassembler_h
#include "6502.h"
#include "common.h"
@ -43,26 +43,23 @@ extern disassembly_t disassembly;
//#define DISASSEMBLER
//#undef DISASSEMBLER
#if defined(DISASSEMBLER) || defined(DEBUGGER)
//extern unsigned long long int clktime;
extern unsigned long long discnt;
//extern unsigned long long int clktime;
extern void _disHexB( char ** s, const uint8_t b );
#define disHexB( s, b ) _disHexB( &(s), (b) )
extern void _disHexW( char ** s, const uint16_t w );
#define disHexW( s, w ) _disHexW( &(s), (w) )
extern void _disPuts( char ** s, const char * from );
#define disPuts( s, from ) _disPuts( &(s), (from) )
extern void _disPrintf( char * s, const size_t n, const char * fmt, ... );
extern void _disNewInstruction(void);
#if defined(DISASSEMBLER) || defined(DEBUGGER)
#define disHexB( s, b ) _disHexB( &(s), (b) )
#define disHexW( s, w ) _disHexW( &(s), (w) )
#define disPuts( s, from ) _disPuts( &(s), (from) )
#define disPrintf( s, fmt, args... ) _disPrintf( (s), sizeof(s), (fmt), ##args )
// TODO: We should add a new field for clk counter, so we can print that out _before_ execution, not after...
extern void _disNewInstruction(void);
#define disNewInstruction() _disNewInstruction()