Addresses directly after a relative branch should not be marked as DATA

in the emulation core, since at that point it's unknown what they are.
I suspect there are other places in the core where this is being done,
so I need to go over the entire M6502.m4 file again.

In Distella, when tentatively marking an address range as CODE, stop
when encountering the first address marked as DATA/GFX/PGFX by the
emulation core.  This is required since Distella will happily disassemble
CODE as far as possible, but addresses specifically marked as
DATA/GFX/PGFX obviously indicate the CODE range is finished.  This is
also why it's so important to correctly mark areas as DATA; the
Distella algorithm depends on accurate information to know when to stop.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2163 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2010-10-24 14:55:42 +00:00
parent bea8ac0ffd
commit 3011aa7d12
3 changed files with 51 additions and 34 deletions

View File

@ -102,8 +102,25 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
myAddressQueue.pop();
disasm(myPC, 1);
if(myPCBeg <= myPCEnd)
{
// Tentatively mark all addresses in the range as CODE
// Note that this is a 'best-effort' approach, since
// Distella will normally keep going until the end of the
// range or branch is encountered
// However, addresses *specifically* marked as DATA/GFX/PGFX
// in the emulation core indicate that the CODE range has finished
// Therefore, we stop at the first such address encountered
for (uInt32 k = myPCBeg; k <= myPCEnd; k++)
{
if(Debugger::debugger().getAddressDisasmType(k) &
(CartDebug::DATA|CartDebug::GFX|CartDebug::PGFX))
{
myPCEnd = k - 1;
break;
}
mark(k, CartDebug::CODE);
}
}
// When we get to this point, all addresses have been processed
// starting from the initial one in the address list

View File

@ -14,7 +14,7 @@
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: M6502.m4 2157 2010-10-21 21:01:00Z stephena $
// $Id: M6502.m4 2158 2010-10-21 21:16:55Z stephena $
//============================================================================
/**
@ -24,7 +24,7 @@
'm4 M6502.m4 > M6502.ins'
@author Bradford W. Mott
@version $Id: M6502.m4 2157 2010-10-21 21:01:00Z stephena $
@version $Id: M6502.m4 2158 2010-10-21 21:16:55Z stephena $
*/
#ifndef NOTSAMEPAGE
@ -916,10 +916,10 @@ case 0x90:
{
if(!C)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}
@ -933,10 +933,10 @@ case 0xb0:
{
if(C)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}
@ -950,10 +950,10 @@ case 0xf0:
{
if(!notZ)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}
@ -993,10 +993,10 @@ case 0x30:
{
if(N)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}
@ -1010,10 +1010,10 @@ case 0xD0:
{
if(notZ)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}
@ -1027,10 +1027,10 @@ case 0x10:
{
if(!N)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}
@ -1062,10 +1062,10 @@ case 0x50:
{
if(!V)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}
@ -1079,10 +1079,10 @@ case 0x70:
{
if(V)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}

View File

@ -268,10 +268,10 @@ define(M6502_INDIRECTY_READMODIFYWRITE, `{
define(M6502_BCC, `{
if(!C)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}')
@ -279,10 +279,10 @@ define(M6502_BCC, `{
define(M6502_BCS, `{
if(C)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}')
@ -290,10 +290,10 @@ define(M6502_BCS, `{
define(M6502_BEQ, `{
if(!notZ)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}')
@ -301,10 +301,10 @@ define(M6502_BEQ, `{
define(M6502_BMI, `{
if(N)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}')
@ -312,10 +312,10 @@ define(M6502_BMI, `{
define(M6502_BNE, `{
if(notZ)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}')
@ -323,10 +323,10 @@ define(M6502_BNE, `{
define(M6502_BPL, `{
if(!N)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}')
@ -334,10 +334,10 @@ define(M6502_BPL, `{
define(M6502_BVC, `{
if(!V)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}')
@ -345,10 +345,10 @@ define(M6502_BVC, `{
define(M6502_BVS, `{
if(V)
{
peek(PC, DISASM_DATA);
peek(PC, DISASM_NONE);
uInt16 address = PC + (Int8)operand;
if(NOTSAMEPAGE(PC, address))
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_DATA);
peek((PC & 0xFF00) | (address & 0x00FF), DISASM_NONE);
PC = address;
}
}')