mirror of
https://github.com/holub/mame
synced 2025-05-23 14:19:01 +03:00
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:
parent
4c95c177a8
commit
7b93ab2d26
@ -191,7 +191,7 @@ static CPU_EXECUTE( ccpu )
|
|||||||
|
|
||||||
cpustate->icount = cycles;
|
cpustate->icount = cycles;
|
||||||
|
|
||||||
while (cpustate->icount >= 0)
|
do
|
||||||
{
|
{
|
||||||
UINT16 tempval;
|
UINT16 tempval;
|
||||||
UINT8 opcode;
|
UINT8 opcode;
|
||||||
@ -673,7 +673,7 @@ static CPU_EXECUTE( ccpu )
|
|||||||
NEXT_ACC_A(cpustate); CYCLES(cpustate, 1);
|
NEXT_ACC_A(cpustate); CYCLES(cpustate, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} while (cpustate->icount > 0);
|
||||||
|
|
||||||
return cycles - cpustate->icount;
|
return cycles - cpustate->icount;
|
||||||
}
|
}
|
||||||
|
@ -1951,7 +1951,7 @@ static CPU_EXECUTE( i960 )
|
|||||||
|
|
||||||
i960->icount = cycles;
|
i960->icount = cycles;
|
||||||
check_irqs(i960);
|
check_irqs(i960);
|
||||||
while(i960->icount >= 0) {
|
while(i960->icount > 0) {
|
||||||
i960->PIP = i960->IP;
|
i960->PIP = i960->IP;
|
||||||
debugger_instruction_hook(device, i960->IP);
|
debugger_instruction_hook(device, i960->IP);
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ static CPU_EXECUTE( mb88 )
|
|||||||
|
|
||||||
cpustate->icount = cycles;
|
cpustate->icount = cycles;
|
||||||
|
|
||||||
while (cpustate->icount >= 0)
|
while (cpustate->icount > 0)
|
||||||
{
|
{
|
||||||
UINT8 opcode, arg, oc;
|
UINT8 opcode, arg, oc;
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@ static CPU_EXECUTE( v60 )
|
|||||||
if (cpustate->irq_line != CLEAR_LINE)
|
if (cpustate->irq_line != CLEAR_LINE)
|
||||||
v60_try_irq(cpustate);
|
v60_try_irq(cpustate);
|
||||||
|
|
||||||
while (cpustate->icount >= 0)
|
while (cpustate->icount > 0)
|
||||||
{
|
{
|
||||||
UINT32 inc;
|
UINT32 inc;
|
||||||
cpustate->PPC = cpustate->PC;
|
cpustate->PPC = cpustate->PC;
|
||||||
|
@ -1018,7 +1018,7 @@ static CPU_EXECUTE( v810 )
|
|||||||
v810_state *cpustate = device->token;
|
v810_state *cpustate = device->token;
|
||||||
|
|
||||||
cpustate->icount = cycles;
|
cpustate->icount = cycles;
|
||||||
while(cpustate->icount>=0)
|
while(cpustate->icount>0)
|
||||||
{
|
{
|
||||||
UINT32 op;
|
UINT32 op;
|
||||||
|
|
||||||
|
@ -989,7 +989,7 @@ void cpu_eat_cycles(const device_config *device, int cycles)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (cycles > *classdata->icount)
|
if (cycles > *classdata->icount)
|
||||||
cycles = *classdata->icount + 1;
|
cycles = *classdata->icount;
|
||||||
*classdata->icount -= cycles;
|
*classdata->icount -= cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1029,7 +1029,7 @@ void cpu_abort_timeslice(const device_config *device)
|
|||||||
/* swallow the remaining cycles */
|
/* swallow the remaining cycles */
|
||||||
if (classdata->icount != NULL)
|
if (classdata->icount != NULL)
|
||||||
{
|
{
|
||||||
delta = *classdata->icount + 1;
|
delta = *classdata->icount;
|
||||||
classdata->cycles_stolen += delta;
|
classdata->cycles_stolen += delta;
|
||||||
classdata->cycles_running -= delta;
|
classdata->cycles_running -= delta;
|
||||||
*classdata->icount -= delta;
|
*classdata->icount -= delta;
|
||||||
|
@ -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 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));
|
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 lastgoodpc = targetpc;
|
||||||
offs_t fillpcbyte, curpc;
|
offs_t fillpcbyte, curpc;
|
||||||
UINT8 opbuf[1024], argbuf[1024];
|
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;
|
fillpcbyte = targetpcbyte;
|
||||||
while (1)
|
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;
|
offs_t scanpc;
|
||||||
int instcount = 0;
|
int instcount = 0;
|
||||||
int instlen;
|
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 */
|
/* loop until we get past the target instruction */
|
||||||
for (scanpc = curpc; scanpc < targetpc; scanpc += instlen)
|
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;
|
offs_t physpcbyte = scanpcbyte;
|
||||||
|
|
||||||
/* get the disassembly, but only if mapped */
|
/* 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);
|
minbytes = cpu_get_min_opcode_bytes(space->cpu);
|
||||||
maxbytes = cpu_get_max_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 */
|
/* set the width of the third column according to display mode */
|
||||||
if (dasmdata->right_column == DASM_RIGHTCOL_RAW || dasmdata->right_column == DASM_RIGHTCOL_ENCRYPTED)
|
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;
|
int numbytes = 0;
|
||||||
|
|
||||||
/* convert PC to a byte offset */
|
/* 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 */
|
/* save a copy of the previous line as a backup if we're only doing one line */
|
||||||
if (lines == 1)
|
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)
|
if (dasmdata->right_column == DASM_RIGHTCOL_RAW || dasmdata->right_column == DASM_RIGHTCOL_ENCRYPTED)
|
||||||
{
|
{
|
||||||
/* get the bytes */
|
/* 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);
|
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)
|
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);
|
exprerr = expression_execute(dasmdata->expression.parsed, &result);
|
||||||
if (exprerr == EXPRERR_NONE && result != dasmdata->expression.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 */
|
/* update the result */
|
||||||
dasmdata->expression.result = result;
|
dasmdata->expression.result = result;
|
||||||
@ -2103,7 +2106,7 @@ recompute:
|
|||||||
{
|
{
|
||||||
const cpu_debug_data *cpuinfo = cpu_get_debug_data(space->cpu);
|
const cpu_debug_data *cpuinfo = cpu_get_debug_data(space->cpu);
|
||||||
for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next)
|
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;
|
attrib = DCA_CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user