summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-09-06 21:56:17 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-09-06 21:56:17 +0000
commitad2a5144adecaec68cabe3156be45320959857df (patch)
treedd5edc7f23c9fd2453803086d2f83fc193bbd2f6 /src
parentf0189a6234e97be03075364d3685d8307ad5c979 (diff)
> 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. >
Diffstat (limited to 'src')
-rw-r--r--src/emu/cpu/i386/i386op32.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/emu/cpu/i386/i386op32.c b/src/emu/cpu/i386/i386op32.c
index e73c60c12d1..c8d06e4aa60 100644
--- a/src/emu/cpu/i386/i386op32.c
+++ b/src/emu/cpu/i386/i386op32.c
@@ -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);
}