summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emu/cpu/i386/i386op16.c63
-rw-r--r--src/emu/cpu/i386/i386op32.c63
-rw-r--r--src/emu/cpu/i386/i386ops.c49
-rw-r--r--src/emu/cpu/i386/i386priv.h34
4 files changed, 97 insertions, 112 deletions
diff --git a/src/emu/cpu/i386/i386op16.c b/src/emu/cpu/i386/i386op16.c
index cdddf91cdf1..6548b1961a0 100644
--- a/src/emu/cpu/i386/i386op16.c
+++ b/src/emu/cpu/i386/i386op16.c
@@ -120,16 +120,14 @@ static void I386OP(adc_rm16_r16)(i386_state *cpustate) // Opcode 0x11
if( modrm >= 0xc0 ) {
src = LOAD_REG16(modrm);
dst = LOAD_RM16(modrm);
- src = ADD16(cpustate,src, cpustate->CF);
- dst = ADD16(cpustate,dst, src);
+ dst = ADC16(cpustate, dst, src, cpustate->CF);
STORE_RM16(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
src = LOAD_REG16(modrm);
dst = READ16(cpustate,ea);
- src = ADD16(cpustate,src, cpustate->CF);
- dst = ADD16(cpustate,dst, src);
+ dst = ADC16(cpustate, dst, src, cpustate->CF);
WRITE16(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -142,16 +140,14 @@ static void I386OP(adc_r16_rm16)(i386_state *cpustate) // Opcode 0x13
if( modrm >= 0xc0 ) {
src = LOAD_RM16(modrm);
dst = LOAD_REG16(modrm);
- src = ADD16(cpustate,src, cpustate->CF);
- dst = ADD16(cpustate,dst, src);
+ dst = ADC16(cpustate, dst, src, cpustate->CF);
STORE_REG16(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
src = READ16(cpustate,ea);
dst = LOAD_REG16(modrm);
- src = ADD16(cpustate,src, cpustate->CF);
- dst = ADD16(cpustate,dst, src);
+ dst = ADC16(cpustate, dst, src, cpustate->CF);
STORE_REG16(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_MEM_REG);
}
@@ -162,8 +158,7 @@ static void I386OP(adc_ax_i16)(i386_state *cpustate) // Opcode 0x15
UINT16 src, dst;
src = FETCH16(cpustate);
dst = REG16(AX);
- src = ADD16(cpustate,src, cpustate->CF);
- dst = ADD16(cpustate,dst, src);
+ dst = ADC16(cpustate, dst, src, cpustate->CF);
REG16(AX) = dst;
CYCLES(cpustate,CYCLES_ALU_IMM_ACC);
}
@@ -1729,16 +1724,16 @@ static void I386OP(sbb_rm16_r16)(i386_state *cpustate) // Opcode 0x19
UINT16 src, dst;
UINT8 modrm = FETCH(cpustate);
if( modrm >= 0xc0 ) {
- src = LOAD_REG16(modrm) + cpustate->CF;
+ src = LOAD_REG16(modrm);
dst = LOAD_RM16(modrm);
- dst = SUB16(cpustate,dst, src);
+ dst = SBB16(cpustate, dst, src, cpustate->CF);
STORE_RM16(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
- src = LOAD_REG16(modrm) + cpustate->CF;
+ src = LOAD_REG16(modrm);
dst = READ16(cpustate,ea);
- dst = SUB16(cpustate,dst, src);
+ dst = SBB16(cpustate, dst, src, cpustate->CF);
WRITE16(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -1749,16 +1744,16 @@ static void I386OP(sbb_r16_rm16)(i386_state *cpustate) // Opcode 0x1b
UINT16 src, dst;
UINT8 modrm = FETCH(cpustate);
if( modrm >= 0xc0 ) {
- src = LOAD_RM16(modrm) + cpustate->CF;
+ src = LOAD_RM16(modrm);
dst = LOAD_REG16(modrm);
- dst = SUB16(cpustate,dst, src);
+ dst = SBB16(cpustate, dst, src, cpustate->CF);
STORE_REG16(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
- src = READ16(cpustate,ea) + cpustate->CF;
+ src = READ16(cpustate,ea);
dst = LOAD_REG16(modrm);
- dst = SUB16(cpustate,dst, src);
+ dst = SBB16(cpustate, dst, src, cpustate->CF);
STORE_REG16(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_MEM_REG);
}
@@ -1767,9 +1762,9 @@ static void I386OP(sbb_r16_rm16)(i386_state *cpustate) // Opcode 0x1b
static void I386OP(sbb_ax_i16)(i386_state *cpustate) // Opcode 0x1d
{
UINT16 src, dst;
- src = FETCH16(cpustate) + cpustate->CF;
+ src = FETCH16(cpustate);
dst = REG16(AX);
- dst = SUB16(cpustate,dst, src);
+ dst = SBB16(cpustate, dst, src, cpustate->CF);
REG16(AX) = dst;
CYCLES(cpustate,CYCLES_ALU_IMM_ACC);
}
@@ -2210,16 +2205,14 @@ static void I386OP(group81_16)(i386_state *cpustate) // Opcode 0x81
if( modrm >= 0xc0 ) {
dst = LOAD_RM16(modrm);
src = FETCH16(cpustate);
- src = ADD16(cpustate,src, cpustate->CF);
- dst = ADD16(cpustate,dst, src);
+ dst = ADC16(cpustate, dst, src, cpustate->CF);
STORE_RM16(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
ea = GetEA(cpustate,modrm);
dst = READ16(cpustate,ea);
src = FETCH16(cpustate);
- src = ADD16(cpustate,src, cpustate->CF);
- dst = ADD16(cpustate,dst, src);
+ dst = ADC16(cpustate, dst, src, cpustate->CF);
WRITE16(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -2227,15 +2220,15 @@ static void I386OP(group81_16)(i386_state *cpustate) // Opcode 0x81
case 3: // SBB Rm16, i16
if( modrm >= 0xc0 ) {
dst = LOAD_RM16(modrm);
- src = FETCH16(cpustate) + cpustate->CF;
- dst = SUB16(cpustate,dst, src);
+ src = FETCH16(cpustate);
+ dst = SBB16(cpustate, dst, src, cpustate->CF);
STORE_RM16(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
ea = GetEA(cpustate,modrm);
dst = READ16(cpustate,ea);
- src = FETCH16(cpustate) + cpustate->CF;
- dst = SUB16(cpustate,dst, src);
+ src = FETCH16(cpustate);
+ dst = SBB16(cpustate, dst, src, cpustate->CF);
WRITE16(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -2349,16 +2342,14 @@ static void I386OP(group83_16)(i386_state *cpustate) // Opcode 0x83
if( modrm >= 0xc0 ) {
dst = LOAD_RM16(modrm);
src = (UINT16)(INT16)(INT8)FETCH(cpustate);
- src = ADD16(cpustate,src, cpustate->CF);
- dst = ADD16(cpustate,dst, src);
+ dst = ADC16(cpustate, dst, src, cpustate->CF);
STORE_RM16(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
ea = GetEA(cpustate,modrm);
dst = READ16(cpustate,ea);
src = (UINT16)(INT16)(INT8)FETCH(cpustate);
- src = ADD16(cpustate,src, cpustate->CF);
- dst = ADD16(cpustate,dst, src);
+ dst = ADC16(cpustate, dst, src, cpustate->CF);
WRITE16(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -2366,15 +2357,15 @@ static void I386OP(group83_16)(i386_state *cpustate) // Opcode 0x83
case 3: // SBB Rm16, i16
if( modrm >= 0xc0 ) {
dst = LOAD_RM16(modrm);
- src = ((UINT16)(INT16)(INT8)FETCH(cpustate)) + cpustate->CF;
- dst = SUB16(cpustate,dst, src);
+ src = ((UINT16)(INT16)(INT8)FETCH(cpustate));
+ dst = SBB16(cpustate, dst, src, cpustate->CF);
STORE_RM16(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
ea = GetEA(cpustate,modrm);
dst = READ16(cpustate,ea);
- src = ((UINT16)(INT16)(INT8)FETCH(cpustate)) + cpustate->CF;
- dst = SUB16(cpustate,dst, src);
+ src = ((UINT16)(INT16)(INT8)FETCH(cpustate));
+ dst = SBB16(cpustate, dst, src, cpustate->CF);
WRITE16(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
diff --git a/src/emu/cpu/i386/i386op32.c b/src/emu/cpu/i386/i386op32.c
index 5fe2fee2d14..e73c60c12d1 100644
--- a/src/emu/cpu/i386/i386op32.c
+++ b/src/emu/cpu/i386/i386op32.c
@@ -122,16 +122,14 @@ static void I386OP(adc_rm32_r32)(i386_state *cpustate) // Opcode 0x11
if( modrm >= 0xc0 ) {
src = LOAD_REG32(modrm);
dst = LOAD_RM32(modrm);
- src = ADD32(cpustate,src, cpustate->CF);
- dst = ADD32(cpustate,dst, src);
+ dst = ADC32(cpustate, dst, src, cpustate->CF);
STORE_RM32(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
src = LOAD_REG32(modrm);
dst = READ32(cpustate,ea);
- src = ADD32(cpustate,src, cpustate->CF);
- dst = ADD32(cpustate,dst, src);
+ dst = ADC32(cpustate, dst, src, cpustate->CF);
WRITE32(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -144,16 +142,14 @@ static void I386OP(adc_r32_rm32)(i386_state *cpustate) // Opcode 0x13
if( modrm >= 0xc0 ) {
src = LOAD_RM32(modrm);
dst = LOAD_REG32(modrm);
- src = ADD32(cpustate,src, cpustate->CF);
- dst = ADD32(cpustate,dst, src);
+ dst = ADC32(cpustate, dst, src, cpustate->CF);
STORE_REG32(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
src = READ32(cpustate,ea);
dst = LOAD_REG32(modrm);
- src = ADD32(cpustate,src, cpustate->CF);
- dst = ADD32(cpustate,dst, src);
+ dst = ADC32(cpustate, dst, src, cpustate->CF);
STORE_REG32(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_MEM_REG);
}
@@ -164,8 +160,7 @@ static void I386OP(adc_eax_i32)(i386_state *cpustate) // Opcode 0x15
UINT32 src, dst;
src = FETCH32(cpustate);
dst = REG32(EAX);
- src = ADD32(cpustate,src, cpustate->CF);
- dst = ADD32(cpustate,dst, src);
+ dst = ADC32(cpustate, dst, src, cpustate->CF);
REG32(EAX) = dst;
CYCLES(cpustate,CYCLES_ALU_IMM_ACC);
}
@@ -1596,16 +1591,16 @@ static void I386OP(sbb_rm32_r32)(i386_state *cpustate) // Opcode 0x19
UINT32 src, dst;
UINT8 modrm = FETCH(cpustate);
if( modrm >= 0xc0 ) {
- src = LOAD_REG32(modrm) + cpustate->CF;
+ src = LOAD_REG32(modrm);
dst = LOAD_RM32(modrm);
- dst = SUB32(cpustate,dst, src);
+ dst = SBB32(cpustate, dst, src, cpustate->CF);
STORE_RM32(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
- src = LOAD_REG32(modrm) + cpustate->CF;
+ src = LOAD_REG32(modrm);
dst = READ32(cpustate,ea);
- dst = SUB32(cpustate,dst, src);
+ dst = SBB32(cpustate, dst, src, cpustate->CF);
WRITE32(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -1616,16 +1611,16 @@ static void I386OP(sbb_r32_rm32)(i386_state *cpustate) // Opcode 0x1b
UINT32 src, dst;
UINT8 modrm = FETCH(cpustate);
if( modrm >= 0xc0 ) {
- src = LOAD_RM32(modrm) + cpustate->CF;
+ src = LOAD_RM32(modrm);
dst = LOAD_REG32(modrm);
- dst = SUB32(cpustate,dst, src);
+ dst = SBB32(cpustate, dst, src, cpustate->CF);
STORE_REG32(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
- src = READ32(cpustate,ea) + cpustate->CF;
+ src = READ32(cpustate,ea);
dst = LOAD_REG32(modrm);
- dst = SUB32(cpustate,dst, src);
+ dst = SBB32(cpustate, dst, src, cpustate->CF);
STORE_REG32(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_MEM_REG);
}
@@ -1634,9 +1629,9 @@ static void I386OP(sbb_r32_rm32)(i386_state *cpustate) // Opcode 0x1b
static void I386OP(sbb_eax_i32)(i386_state *cpustate) // Opcode 0x1d
{
UINT32 src, dst;
- src = FETCH32(cpustate) + cpustate->CF;
+ src = FETCH32(cpustate);
dst = REG32(EAX);
- dst = SUB32(cpustate,dst, src);
+ dst = SBB32(cpustate, dst, src, cpustate->CF);
REG32(EAX) = dst;
CYCLES(cpustate,CYCLES_ALU_IMM_ACC);
}
@@ -2059,16 +2054,14 @@ static void I386OP(group81_32)(i386_state *cpustate) // Opcode 0x81
if( modrm >= 0xc0 ) {
dst = LOAD_RM32(modrm);
src = FETCH32(cpustate);
- src = ADD32(cpustate,src, cpustate->CF);
- dst = ADD32(cpustate,dst, src);
+ dst = ADC32(cpustate, dst, src, cpustate->CF);
STORE_RM32(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
ea = GetEA(cpustate,modrm);
dst = READ32(cpustate,ea);
src = FETCH32(cpustate);
- src = ADD32(cpustate,src, cpustate->CF);
- dst = ADD32(cpustate,dst, src);
+ dst = ADC32(cpustate, dst, src, cpustate->CF);
WRITE32(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -2076,15 +2069,15 @@ static void I386OP(group81_32)(i386_state *cpustate) // Opcode 0x81
case 3: // SBB Rm32, i32
if( modrm >= 0xc0 ) {
dst = LOAD_RM32(modrm);
- src = FETCH32(cpustate) + cpustate->CF;
- dst = SUB32(cpustate,dst, src);
+ src = FETCH32(cpustate);
+ dst = SBB32(cpustate, dst, src, cpustate->CF);
STORE_RM32(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
ea = GetEA(cpustate,modrm);
dst = READ32(cpustate,ea);
- src = FETCH32(cpustate) + cpustate->CF;
- dst = SUB32(cpustate,dst, src);
+ src = FETCH32(cpustate);
+ dst = SBB32(cpustate, dst, src, cpustate->CF);
WRITE32(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -2198,16 +2191,14 @@ static void I386OP(group83_32)(i386_state *cpustate) // Opcode 0x83
if( modrm >= 0xc0 ) {
dst = LOAD_RM32(modrm);
src = (UINT32)(INT32)(INT8)FETCH(cpustate);
- src = ADD32(cpustate,src, cpustate->CF);
- dst = ADD32(cpustate,dst, src);
+ dst = ADC32(cpustate, dst, src, cpustate->CF);
STORE_RM32(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
ea = GetEA(cpustate,modrm);
dst = READ32(cpustate,ea);
src = (UINT32)(INT32)(INT8)FETCH(cpustate);
- src = ADD32(cpustate,src, cpustate->CF);
- dst = ADD32(cpustate,dst, src);
+ dst = ADC32(cpustate, dst, src, cpustate->CF);
WRITE32(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -2215,15 +2206,15 @@ static void I386OP(group83_32)(i386_state *cpustate) // Opcode 0x83
case 3: // SBB Rm32, i32
if( modrm >= 0xc0 ) {
dst = LOAD_RM32(modrm);
- src = ((UINT32)(INT32)(INT8)FETCH(cpustate)) + cpustate->CF;
- dst = SUB32(cpustate,dst, src);
+ src = ((UINT32)(INT32)(INT8)FETCH(cpustate));
+ dst = SBB32(cpustate, dst, src, cpustate->CF);
STORE_RM32(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
ea = GetEA(cpustate,modrm);
dst = READ32(cpustate,ea);
- src = ((UINT32)(INT32)(INT8)FETCH(cpustate)) + cpustate->CF;
- dst = SUB32(cpustate,dst, src);
+ src = ((UINT32)(INT32)(INT8)FETCH(cpustate));
+ dst = SBB32(cpustate, dst, src, cpustate->CF);
WRITE32(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
diff --git a/src/emu/cpu/i386/i386ops.c b/src/emu/cpu/i386/i386ops.c
index ab8f51f95ed..c336c976021 100644
--- a/src/emu/cpu/i386/i386ops.c
+++ b/src/emu/cpu/i386/i386ops.c
@@ -121,16 +121,14 @@ static void I386OP(adc_rm8_r8)(i386_state *cpustate) // Opcode 0x10
if( modrm >= 0xc0 ) {
src = LOAD_REG8(modrm);
dst = LOAD_RM8(modrm);
- src = ADD8(cpustate,src, cpustate->CF);
- dst = ADD8(cpustate,dst, src);
+ dst = ADC8(cpustate, dst, src, cpustate->CF);
STORE_RM8(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
src = LOAD_REG8(modrm);
dst = READ8(cpustate,ea);
- src = ADD8(cpustate,src, cpustate->CF);
- dst = ADD8(cpustate,dst, src);
+ dst = ADC8(cpustate, dst, src, cpustate->CF);
WRITE8(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -143,16 +141,14 @@ static void I386OP(adc_r8_rm8)(i386_state *cpustate) // Opcode 0x12
if( modrm >= 0xc0 ) {
src = LOAD_RM8(modrm);
dst = LOAD_REG8(modrm);
- src = ADD8(cpustate,src, cpustate->CF);
- dst = ADD8(cpustate,dst, src);
+ dst = ADC8(cpustate, dst, src, cpustate->CF);
STORE_REG8(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
src = READ8(cpustate,ea);
dst = LOAD_REG8(modrm);
- src = ADD8(cpustate,src, cpustate->CF);
- dst = ADD8(cpustate,dst, src);
+ dst = ADC8(cpustate, dst, src, cpustate->CF);
STORE_REG8(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_MEM_REG);
}
@@ -163,8 +159,7 @@ static void I386OP(adc_al_i8)(i386_state *cpustate) // Opcode 0x14
UINT8 src, dst;
src = FETCH(cpustate);
dst = REG8(AL);
- src = ADD8(cpustate,src, cpustate->CF);
- dst = ADD8(cpustate,dst, src);
+ dst = ADC8(cpustate, dst, src, cpustate->CF);
REG8(AL) = dst;
CYCLES(cpustate,CYCLES_ALU_IMM_ACC);
}
@@ -1141,16 +1136,16 @@ static void I386OP(sbb_rm8_r8)(i386_state *cpustate) // Opcode 0x18
UINT8 src, dst;
UINT8 modrm = FETCH(cpustate);
if( modrm >= 0xc0 ) {
- src = LOAD_REG8(modrm) + cpustate->CF;
+ src = LOAD_REG8(modrm);
dst = LOAD_RM8(modrm);
- dst = SUB8(cpustate,dst, src);
+ dst = SBB8(cpustate, dst, src, cpustate->CF);
STORE_RM8(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
- src = LOAD_REG8(modrm) + cpustate->CF;
+ src = LOAD_REG8(modrm);
dst = READ8(cpustate,ea);
- dst = SUB8(cpustate,dst, src);
+ dst = SBB8(cpustate, dst, src, cpustate->CF);
WRITE8(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -1161,16 +1156,16 @@ static void I386OP(sbb_r8_rm8)(i386_state *cpustate) // Opcode 0x1a
UINT8 src, dst;
UINT8 modrm = FETCH(cpustate);
if( modrm >= 0xc0 ) {
- src = LOAD_RM8(modrm) + cpustate->CF;
+ src = LOAD_RM8(modrm);
dst = LOAD_REG8(modrm);
- dst = SUB8(cpustate,dst, src);
+ dst = SBB8(cpustate, dst, src, cpustate->CF);
STORE_REG8(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
UINT32 ea = GetEA(cpustate,modrm);
- src = READ8(cpustate,ea) + cpustate->CF;
+ src = READ8(cpustate,ea);
dst = LOAD_REG8(modrm);
- dst = SUB8(cpustate,dst, src);
+ dst = SBB8(cpustate, dst, src, cpustate->CF);
STORE_REG8(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_MEM_REG);
}
@@ -1179,9 +1174,9 @@ static void I386OP(sbb_r8_rm8)(i386_state *cpustate) // Opcode 0x1a
static void I386OP(sbb_al_i8)(i386_state *cpustate) // Opcode 0x1c
{
UINT8 src, dst;
- src = FETCH(cpustate) + cpustate->CF;
+ src = FETCH(cpustate);
dst = REG8(AL);
- dst = SUB8(cpustate,dst, src);
+ dst = SBB8(cpustate, dst, src, cpustate->CF);
REG8(EAX) = dst;
CYCLES(cpustate,CYCLES_ALU_IMM_ACC);
}
@@ -1707,16 +1702,14 @@ static void I386OP(group80_8)(i386_state *cpustate) // Opcode 0x80
if( modrm >= 0xc0 ) {
dst = LOAD_RM8(modrm);
src = FETCH(cpustate);
- src = ADD8(cpustate,src, cpustate->CF);
- dst = ADD8(cpustate,dst, src);
+ dst = ADC8(cpustate, dst, src, cpustate->CF);
STORE_RM8(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
ea = GetEA(cpustate,modrm);
dst = READ8(cpustate,ea);
src = FETCH(cpustate);
- src = ADD8(cpustate,src, cpustate->CF);
- dst = ADD8(cpustate,dst, src);
+ dst = ADC8(cpustate, dst, src, cpustate->CF);
WRITE8(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
@@ -1724,15 +1717,15 @@ static void I386OP(group80_8)(i386_state *cpustate) // Opcode 0x80
case 3: // SBB Rm8, i8
if( modrm >= 0xc0 ) {
dst = LOAD_RM8(modrm);
- src = FETCH(cpustate) + cpustate->CF;
- dst = SUB8(cpustate,dst, src);
+ src = FETCH(cpustate);
+ dst = SBB8(cpustate, dst, src, cpustate->CF);
STORE_RM8(modrm, dst);
CYCLES(cpustate,CYCLES_ALU_REG_REG);
} else {
ea = GetEA(cpustate,modrm);
dst = READ8(cpustate,ea);
- src = FETCH(cpustate) + cpustate->CF;
- dst = SUB8(cpustate,dst, src);
+ src = FETCH(cpustate);
+ dst = SBB8(cpustate, dst, src, cpustate->CF);
WRITE8(cpustate,ea, dst);
CYCLES(cpustate,CYCLES_ALU_REG_MEM);
}
diff --git a/src/emu/cpu/i386/i386priv.h b/src/emu/cpu/i386/i386priv.h
index 9d0b450b52d..f6d3b70ee1a 100644
--- a/src/emu/cpu/i386/i386priv.h
+++ b/src/emu/cpu/i386/i386priv.h
@@ -691,27 +691,32 @@ INLINE UINT32 XOR32(i386_state *cpustate,UINT32 dst, UINT32 src)
return res;
}
-INLINE UINT8 SUB8(i386_state *cpustate,UINT8 dst, UINT8 src)
+#define SUB8(cpu, dst, src) SBB8(cpu, dst, src, 0)
+INLINE UINT8 SBB8(i386_state *cpustate,UINT8 dst, UINT8 src, UINT8 b)
{
- UINT16 res = (UINT16)dst - (UINT16)src;
+ UINT16 res = (UINT16)dst - (UINT16)src - (UINT8)b;
SetCF8(res);
SetOF_Sub8(res,src,dst);
SetAF(res,src,dst);
SetSZPF8(res);
return (UINT8)res;
}
-INLINE UINT16 SUB16(i386_state *cpustate,UINT16 dst, UINT16 src)
+
+#define SUB16(cpu, dst, src) SBB16(cpu, dst, src, 0)
+INLINE UINT16 SBB16(i386_state *cpustate,UINT16 dst, UINT16 src, UINT16 b)
{
- UINT32 res = (UINT32)dst - (UINT32)src;
+ UINT32 res = (UINT32)dst - (UINT32)src - (UINT32)b;
SetCF16(res);
SetOF_Sub16(res,src,dst);
SetAF(res,src,dst);
SetSZPF16(res);
return (UINT16)res;
}
-INLINE UINT32 SUB32(i386_state *cpustate,UINT32 dst, UINT32 src)
+
+#define SUB32(cpu, dst, src) SBB32(cpu, dst, src, 0)
+INLINE UINT32 SBB32(i386_state *cpustate,UINT32 dst, UINT32 src, UINT32 b)
{
- UINT64 res = (UINT64)dst - (UINT64)src;
+ UINT64 res = (UINT64)dst - (UINT64)src - (UINT64) b;
SetCF32(res);
SetOF_Sub32(res,src,dst);
SetAF(res,src,dst);
@@ -719,27 +724,32 @@ INLINE UINT32 SUB32(i386_state *cpustate,UINT32 dst, UINT32 src)
return (UINT32)res;
}
-INLINE UINT8 ADD8(i386_state *cpustate,UINT8 dst, UINT8 src)
+#define ADD8(cpu, dst, src) ADC8(cpu, dst, src, 0)
+INLINE UINT8 ADC8(i386_state *cpustate,UINT8 dst, UINT8 src, UINT8 c)
{
- UINT16 res = (UINT16)dst + (UINT16)src;
+ UINT16 res = (UINT16)dst + (UINT16)src + (UINT16)c;
SetCF8(res);
SetOF_Add8(res,src,dst);
SetAF(res,src,dst);
SetSZPF8(res);
return (UINT8)res;
}
-INLINE UINT16 ADD16(i386_state *cpustate,UINT16 dst, UINT16 src)
+
+#define ADD16(cpu, dst, src) ADC16(cpu, dst, src, 0)
+INLINE UINT16 ADC16(i386_state *cpustate,UINT16 dst, UINT16 src, UINT8 c)
{
- UINT32 res = (UINT32)dst + (UINT32)src;
+ UINT32 res = (UINT32)dst + (UINT32)src + (UINT32)c;
SetCF16(res);
SetOF_Add16(res,src,dst);
SetAF(res,src,dst);
SetSZPF16(res);
return (UINT16)res;
}
-INLINE UINT32 ADD32(i386_state *cpustate,UINT32 dst, UINT32 src)
+
+#define ADD32(cpu, dst, src) ADC32(cpu, dst, src, 0)
+INLINE UINT32 ADC32(i386_state *cpustate,UINT32 dst, UINT32 src, UINT32 c)
{
- UINT64 res = (UINT64)dst + (UINT64)src;
+ UINT64 res = (UINT64)dst + (UINT64)src + (UINT64) c;
SetCF32(res);
SetOF_Add32(res,src,dst);
SetAF(res,src,dst);