}
+static uint32_t or32 (CPU8086 *cpu, uint32_t a, uint32_t b) {
+
+ uint32_t result = a | b;
+
+ cpu->flags &= (uint16_t) ~(FLAG_CF | FLAG_OF);
+ update_common_flags32 (cpu, result);
+
+ return result;
+
+}
+
static uint32_t xor32 (CPU8086 *cpu, uint32_t a, uint32_t b) {
uint32_t result = a ^ b;
operand_write32 (cpu, &rm, add32 (cpu, operand_read32 (cpu, &rm), get_reg32 (cpu, reg)));
} else if (op == 0x03) {
set_reg32 (cpu, reg, add32 (cpu, get_reg32 (cpu, reg), operand_read32 (cpu, &rm)));
+ } else if (op == 0x0B) {
+ set_reg32 (cpu, reg, or32 (cpu, get_reg32 (cpu, reg), operand_read32 (cpu, &rm)));
} else if (op == 0x29) {
operand_write32 (cpu, &rm, sub32 (cpu, operand_read32 (cpu, &rm), get_reg32 (cpu, reg)));
} else if (op == 0x2B) {
break;
/* --- Segment Registers --- */
- case 0x06: /* PUSH ES */
+ case 0x06: /* PUSH ES */
push16 (cpu, cpu->es);
break;
}
- case 0x0E: /* PUSH CS */
+ case 0x0E: /* PUSH CS */
push16 (cpu, cpu->cs);
break;
}
- case 0x16: /* PUSH SS */
+ case 0x16: /* PUSH SS */
push16 (cpu, cpu->ss);
break;
- case 0x17: /* POP SS */
+ case 0x17: /* POP SS */
if (cpu_load_segment (cpu, 2, pop16 (cpu)) != 0) {
return -1;
trap_inhibit = 1;
break;
- case 0x1E: /* PUSH DS */
+ case 0x1E: /* PUSH DS */
push16 (cpu, cpu->ds);
break;
- case 0x1F: /* POP DS */
+ case 0x1F: /* POP DS */
if (cpu_load_segment (cpu, 3, pop16 (cpu)) != 0) {
return -1;
}
- case 0x90: /* NOP (XCHG AX, AX) */
+ case 0x90: /* NOP (XCHG AX, AX) */
break;
}
- case 0x99: /* CWD - Convert Word to Doubleword */
+ case 0x99: /* CWD - Convert Word to Doubleword */
if (cpu->regs[REG_AX] & 0x8000) {
cpu->regs[REG_DX] = 0xFFFF;
}
- case 0x9C: /* PUSHF (Push Flags onto Stack) */
+ case 0x9C: /* PUSHF (Push Flags onto Stack) */
if (cpu->has_operand_override) {
push32 (cpu, (cpu->eflags_high & 0x003F0000UL) | cpu->flags);
switch (subop) {
- case 0: /* ROL */
+ case 0: /* ROL */
for (int i = 0; i < count; i++) {
break;
- case 4: /* SHL / SAL */
+ case 4: /* SHL / SAL */
if (count > 8) {
update_common_flags8 (cpu, result);
break;
- case 5: /* SHR */
+ case 5: /* SHR */
if (count > 8) {
}
- case 0xC9: /* LEAVE */
+ case 0xC9: /* LEAVE */
cpu->regs[REG_SP] = cpu->regs[REG_BP];
cpu->regs[REG_BP] = pop16 (cpu);
switch (subop) {
- case 0: /* INC rm16 */
+ case 0: /* INC rm16 */
operand_write16 (cpu, &rm, inc16 (cpu, operand_read16 (cpu, &rm)));
break;
- case 1: /* DEC rm16 */
+ case 1: /* DEC rm16 */
operand_write16 (cpu, &rm, dec16 (cpu, operand_read16 (cpu, &rm)));
break;
}
- case 3: /* CALL far indirect */
+ case 3: /* CALL far indirect */
if (!rm.is_mem) {
return -1;
break;
- case 4: /* JMP near indirect */
+ case 4: /* JMP near indirect */
cpu->ip = operand_read16 (cpu, &rm);
break;
- case 5: /* JMP far indirect (m16:16) */
+ case 5: /* JMP far indirect (m16:16) */
if (!rm.is_mem) {
return -1;
break;
- case 6: /* PUSH rm16 */
+ case 6: /* PUSH rm16 */
push16 (cpu, operand_read16 (cpu, &rm));
break;
switch (subop) {
- case 0: /* ROL (Rotate Left) */
+ case 0: /* ROL (Rotate Left) */
result = (val << 1) | (val >> 7);
break;
- case 1: /* ROR (Rotate Right) */
+ case 1: /* ROR (Rotate Right) */
result = (val >> 1) | (val << 7);
break;
- case 2: /* RCL (Rotate through Carry Left) */
+ case 2: /* RCL (Rotate through Carry Left) */
result = (val << 1) | old_cf;
break;
- case 3: /* RCR (Rotate through Carry Right) */
+ case 3: /* RCR (Rotate through Carry Right) */
result = (val >> 1) | (old_cf << 7);
break;
- case 4: /* SHL / SAL */
+ case 4: /* SHL / SAL */
result = val << 1;
update_common_flags8 (cpu, result); /* Shifts DO affect ZF/SF/PF */
break;
- case 5: /* SHR */
+ case 5: /* SHR */
result = val >> 1;
update_common_flags8 (cpu, result);
break;
- case 7: /* SAR */
+ case 7: /* SAR */
result = (uint8_t) ((int8_t) val >> 1);
switch (subop) {
- case 0: /* ROL (Rotate Left) */
+ case 0: /* ROL (Rotate Left) */
result = (val << 1) | (val >> 15);
break;
- case 1: /* ROR (Rotate Right) */
+ case 1: /* ROR (Rotate Right) */
result = (val >> 1) | (val << 15);
break;
- case 2: /* RCL (Rotate through Carry Left) */
+ case 2: /* RCL (Rotate through Carry Left) */
result = (val << 1) | old_cf;
break;
- case 3: /* RCR (Rotate through Carry Right) */
+ case 3: /* RCR (Rotate through Carry Right) */
result = (val >> 1) | ((uint16_t) old_cf << 15);
break;
- case 4: /* SHL / SAL */
+ case 4: /* SHL / SAL */
result = val << 1;
update_common_flags16 (cpu, result);
break;
- case 5: /* SHR */
+ case 5: /* SHR */
result = val >> 1;
update_common_flags16 (cpu, result);
break;
- case 7: /* SAR */
+ case 7: /* SAR */
result = (uint16_t) ((int16_t) val >> 1);
switch (subop) {
- case 0: /* ROL */
+ case 0: /* ROL */
for (int i = 0; i < count; i++) {
break;
- case 1: /* ROR */
+ case 1: /* ROR */
for (int i = 0; i < count; i++) {
break;
- case 2: /* RCL */
+ case 2: /* RCL */
for (int i = 0; i < count; i++) {
break;
- case 3: /* RCR */
+ case 3: /* RCR */
for (int i = 0; i < count; i++) {
break;
- case 4: /* SHL / SAL */
+ case 4: /* SHL / SAL */
if (count >= 8) {
update_common_flags8 (cpu, result);
break;
- case 5: /* SHR */
+ case 5: /* SHR */
if (count >= 8) {
update_common_flags8 (cpu, result);
break;
- case 7: /* SAR */
+ case 7: /* SAR */
if (count >= 8) {
}
- case 0xF0: /* LOCK prefix */
+ case 0xF0: /* LOCK prefix */
goto fetch_instruction;
- case 0xF2: /* REPNZ */
+ case 0xF2: /* REPNZ */
cpu->rep_type = 2;
goto fetch_instruction;
- case 0xF3: /* REP / REPE */
+ case 0xF3: /* REP / REPE */
cpu->rep_type = 1;
goto fetch_instruction;
break;
}
- case 2: /* NOT rm8 */
+ case 2: /* NOT rm8 */
operand_write8 (cpu, &rm, ~operand_read8 (cpu, &rm));
break;
- case 3: /* NEG rm8 */
+ case 3: /* NEG rm8 */
operand_write8 (cpu, &rm, sub8 (cpu, 0, operand_read8 (cpu, &rm)));
break;
and16 (cpu, operand_read16 (cpu, &rm), fetch16 (cpu));
break;
- case 2: /* NOT rm16 */
+ case 2: /* NOT rm16 */
operand_write16 (cpu, &rm, ~operand_read16 (cpu, &rm));
break;
- case 3: /* NEG rm16 */
+ case 3: /* NEG rm16 */
operand_write16 (cpu, &rm, sub16 (cpu, 0, operand_read16 (cpu, &rm)));
break;
}
- case 0xF8: /* CLC (Clear Carry Flag) */
+ case 0xF8: /* CLC (Clear Carry Flag) */
cpu->flags &= (uint16_t) ~FLAG_CF;
break;
- case 0xF9: /* STC (Set Carry Flag) */
+ case 0xF9: /* STC (Set Carry Flag) */
cpu->flags |= FLAG_CF;
break;
- case 0xF5: /* CMC (Complement Carry Flag) */
+ case 0xF5: /* CMC (Complement Carry Flag) */
cpu->flags ^= FLAG_CF;
break;
}
- case 0xFC: /* CLD (Clear Direction Flag) */
+ case 0xFC: /* CLD (Clear Direction Flag) */
cpu->flags &= (uint16_t) ~FLAG_DF;
break;
- case 0xFD: /* STD (Set Direction Flag) */
+ case 0xFD: /* STD (Set Direction Flag) */
cpu->flags |= FLAG_DF;
break;