diff --git a/src/emu/cpu/ccpu/ccpu.c b/src/emu/cpu/ccpu/ccpu.c index 49f0452b60e..3b4545f73f2 100644 --- a/src/emu/cpu/ccpu/ccpu.c +++ b/src/emu/cpu/ccpu/ccpu.c @@ -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; } diff --git a/src/emu/cpu/i960/i960.c b/src/emu/cpu/i960/i960.c index fd91a613436..bd4d51144ce 100644 --- a/src/emu/cpu/i960/i960.c +++ b/src/emu/cpu/i960/i960.c @@ -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); diff --git a/src/emu/cpu/mb88xx/mb88xx.c b/src/emu/cpu/mb88xx/mb88xx.c index b67a3258986..84f4a964a5c 100644 --- a/src/emu/cpu/mb88xx/mb88xx.c +++ b/src/emu/cpu/mb88xx/mb88xx.c @@ -220,7 +220,7 @@ static CPU_EXECUTE( mb88 ) cpustate->icount = cycles; - while (cpustate->icount >= 0) + while (cpustate->icount > 0) { UINT8 opcode, arg, oc; diff --git a/src/emu/cpu/v60/v60.c b/src/emu/cpu/v60/v60.c index 9495602e19c..a7c2126b291 100644 --- a/src/emu/cpu/v60/v60.c +++ b/src/emu/cpu/v60/v60.c @@ -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; diff --git a/src/emu/cpu/v810/v810.c b/src/emu/cpu/v810/v810.c index 8b90b76705b..11185d49cd5 100644 --- a/src/emu/cpu/v810/v810.c +++ b/src/emu/cpu/v810/v810.c @@ -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; diff --git a/src/emu/cpuexec.c b/src/emu/cpuexec.c index 0c60411bd53..9917ffa88e3 100644 --- a/src/emu/cpuexec.c +++ b/src/emu/cpuexec.c @@ -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; diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c index 9099bff38a5..76a3684b8ad 100644 --- a/src/emu/debug/debugvw.c +++ b/src/emu/debug/debugvw.c @@ -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; }