> From: Gabriele Gorla [mailto:gorlik@penguintown.net]

> Sent: Saturday, September 05, 2009 2:11 PM
> To: submit@mamedev.org
> Subject: I386: fix loop instructions when address_size is 16-bit
> 
> Original code always assume address_size to be 32-bit
> The patch will use the correct size based on the status of the
> address_size flag.
>
This commit is contained in:
Aaron Giles 2009-09-06 21:56:17 +00:00
parent f0189a6234
commit ad2a5144ad

View File

@ -1021,8 +1021,8 @@ static void I386OP(lodsd)(i386_state *cpustate) // Opcode 0xad
static void I386OP(loop32)(i386_state *cpustate) // Opcode 0xe2
{
INT8 disp = FETCH(cpustate);
REG32(ECX)--;
if( REG32(ECX) != 0 ) {
INT32 reg = (cpustate->address_size)?--REG32(ECX):--REG16(CX);
if( reg != 0 ) {
cpustate->eip += disp;
CHANGE_PC(cpustate,cpustate->eip);
}
@ -1032,8 +1032,8 @@ static void I386OP(loop32)(i386_state *cpustate) // Opcode 0xe2
static void I386OP(loopne32)(i386_state *cpustate) // Opcode 0xe0
{
INT8 disp = FETCH(cpustate);
REG32(ECX)--;
if( REG32(ECX) != 0 && cpustate->ZF == 0 ) {
INT32 reg = (cpustate->address_size)?--REG32(ECX):--REG16(CX);
if( reg != 0 && cpustate->ZF == 0 ) {
cpustate->eip += disp;
CHANGE_PC(cpustate,cpustate->eip);
}
@ -1043,8 +1043,8 @@ static void I386OP(loopne32)(i386_state *cpustate) // Opcode 0xe0
static void I386OP(loopz32)(i386_state *cpustate) // Opcode 0xe1
{
INT8 disp = FETCH(cpustate);
REG32(ECX)--;
if( REG32(ECX) != 0 && cpustate->ZF != 0 ) {
INT32 reg = (cpustate->address_size)?--REG32(ECX):--REG16(CX);
if( reg != 0 && cpustate->ZF != 0 ) {
cpustate->eip += disp;
CHANGE_PC(cpustate,cpustate->eip);
}