02783: SMS-Based megatech.c sets: [debug] Access Violation with -debug

Disassembled PCs are now forcibly aligned to the minimum opcode size
and explicitly masked.

Also normalized the CPU cores to always do while (icount > 0), in order
to remove the kludge in cpuexec.c that caused us to overeat by 1 cycle to
accommodate those cores that there looping while (icount >= 0).
This commit is contained in:
Aaron Giles 2008-12-30 01:18:26 +00:00
parent 4c95c177a8
commit 7b93ab2d26
7 changed files with 18 additions and 15 deletions

View File

@ -191,7 +191,7 @@ static CPU_EXECUTE( ccpu )
cpustate->icount = cycles;
while (cpustate->icount >= 0)
do
{
UINT16 tempval;
UINT8 opcode;
@ -673,7 +673,7 @@ static CPU_EXECUTE( ccpu )
NEXT_ACC_A(cpustate); CYCLES(cpustate, 1);
break;
}
}
} while (cpustate->icount > 0);
return cycles - cpustate->icount;
}

View File

@ -1951,7 +1951,7 @@ static CPU_EXECUTE( i960 )
i960->icount = cycles;
check_irqs(i960);
while(i960->icount >= 0) {
while(i960->icount > 0) {
i960->PIP = i960->IP;
debugger_instruction_hook(device, i960->IP);

View File

@ -220,7 +220,7 @@ static CPU_EXECUTE( mb88 )
cpustate->icount = cycles;
while (cpustate->icount >= 0)
while (cpustate->icount > 0)
{
UINT8 opcode, arg, oc;

View File

@ -456,7 +456,7 @@ static CPU_EXECUTE( v60 )
if (cpustate->irq_line != CLEAR_LINE)
v60_try_irq(cpustate);
while (cpustate->icount >= 0)
while (cpustate->icount > 0)
{
UINT32 inc;
cpustate->PPC = cpustate->PC;

View File

@ -1018,7 +1018,7 @@ static CPU_EXECUTE( v810 )
v810_state *cpustate = device->token;
cpustate->icount = cycles;
while(cpustate->icount>=0)
while(cpustate->icount>0)
{
UINT32 op;

View File

@ -989,7 +989,7 @@ void cpu_eat_cycles(const device_config *device, int cycles)
return;
if (cycles > *classdata->icount)
cycles = *classdata->icount + 1;
cycles = *classdata->icount;
*classdata->icount -= cycles;
}
@ -1029,7 +1029,7 @@ void cpu_abort_timeslice(const device_config *device)
/* swallow the remaining cycles */
if (classdata->icount != NULL)
{
delta = *classdata->icount + 1;
delta = *classdata->icount;
classdata->cycles_stolen += delta;
classdata->cycles_running -= delta;
*classdata->icount -= delta;

View File

@ -1690,7 +1690,7 @@ static offs_t disasm_view_find_pc_backwards(const address_space *space, offs_t t
{
int minlen = memory_byte_to_address(space, cpu_get_min_opcode_bytes(space->cpu));
int maxlen = memory_byte_to_address(space, cpu_get_max_opcode_bytes(space->cpu));
offs_t targetpcbyte = memory_address_to_byte(space, targetpc);
offs_t targetpcbyte = memory_address_to_byte(space, targetpc) & space->logbytemask;
offs_t lastgoodpc = targetpc;
offs_t fillpcbyte, curpc;
UINT8 opbuf[1024], argbuf[1024];
@ -1709,7 +1709,7 @@ static offs_t disasm_view_find_pc_backwards(const address_space *space, offs_t t
fillpcbyte = targetpcbyte;
while (1)
{
offs_t curpcbyte = memory_address_to_byte(space, curpc);
offs_t curpcbyte = memory_address_to_byte(space, curpc) & space->logbytemask;
offs_t scanpc;
int instcount = 0;
int instlen;
@ -1725,7 +1725,7 @@ static offs_t disasm_view_find_pc_backwards(const address_space *space, offs_t t
/* loop until we get past the target instruction */
for (scanpc = curpc; scanpc < targetpc; scanpc += instlen)
{
offs_t scanpcbyte = memory_address_to_byte(space, scanpc);
offs_t scanpcbyte = memory_address_to_byte(space, scanpc) & space->logbytemask;
offs_t physpcbyte = scanpcbyte;
/* get the disassembly, but only if mapped */
@ -1840,6 +1840,9 @@ static int disasm_view_recompute(debug_view *view, offs_t pc, int startline, int
minbytes = cpu_get_min_opcode_bytes(space->cpu);
maxbytes = cpu_get_max_opcode_bytes(space->cpu);
/* ensure that the PC is aligned to the minimum opcode size */
pc &= ~memory_byte_to_address_end(space, minbytes - 1);
/* set the width of the third column according to display mode */
if (dasmdata->right_column == DASM_RIGHTCOL_RAW || dasmdata->right_column == DASM_RIGHTCOL_ENCRYPTED)
{
@ -1879,7 +1882,7 @@ static int disasm_view_recompute(debug_view *view, offs_t pc, int startline, int
int numbytes = 0;
/* convert PC to a byte offset */
pcbyte = memory_address_to_byte(space, pc);
pcbyte = memory_address_to_byte(space, pc) & space->logbytemask;
/* save a copy of the previous line as a backup if we're only doing one line */
if (lines == 1)
@ -1915,7 +1918,7 @@ static int disasm_view_recompute(debug_view *view, offs_t pc, int startline, int
if (dasmdata->right_column == DASM_RIGHTCOL_RAW || dasmdata->right_column == DASM_RIGHTCOL_ENCRYPTED)
{
/* get the bytes */
numbytes = memory_address_to_byte(space, numbytes);
numbytes = memory_address_to_byte(space, numbytes) & space->logbytemask;
disasm_view_generate_bytes(space, pcbyte, numbytes, minbytes, &destbuf[dasmdata->divider2], dasmdata->allocated.x - dasmdata->divider2, dasmdata->right_column == DASM_RIGHTCOL_ENCRYPTED);
}
else if (dasmdata->right_column == DASM_RIGHTCOL_COMMENTS)
@ -1995,7 +1998,7 @@ static void disasm_view_update(debug_view *view)
exprerr = expression_execute(dasmdata->expression.parsed, &result);
if (exprerr == EXPRERR_NONE && result != dasmdata->expression.result)
{
offs_t resultbyte = memory_address_to_byte(space, result);
offs_t resultbyte = memory_address_to_byte(space, result) & space->logbytemask;
/* update the result */
dasmdata->expression.result = result;
@ -2103,7 +2106,7 @@ recompute:
{
const cpu_debug_data *cpuinfo = cpu_get_debug_data(space->cpu);
for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next)
if (dasmdata->byteaddress[effrow] == memory_address_to_byte(space, bp->address))
if (dasmdata->byteaddress[effrow] == (memory_address_to_byte(space, bp->address) & space->logbytemask))
attrib = DCA_CHANGED;
}