rev |
line source |
pascal@20279
|
1 --- 8086tiny.c
|
pascal@20279
|
2 +++ 8086tiny.c
|
pascal@20279
|
3 @@ -112,8 +112,9 @@
|
pascal@20279
|
4 regs16[REG_AX] = op_result, \
|
pascal@20279
|
5 set_OF(set_CF(op_result - (op_data_type)op_result)))
|
pascal@20279
|
6 #define DIV_MACRO(out_data_type,in_data_type,out_regs) (scratch_int = CAST(out_data_type)mem[rm_addr]) && !(scratch2_uint = (in_data_type)(scratch_uint = (out_regs[i_w+1] << 16) + regs16[REG_AX]) / scratch_int, scratch2_uint - (out_data_type)scratch2_uint) ? out_regs[i_w+1] = scratch_uint - scratch_int * (*out_regs = scratch2_uint) : pc_interrupt(0)
|
pascal@20279
|
7 -#define DAA_DAS(op1,op2,mask,min) set_AF((((scratch2_uint = regs8[REG_AL]) & 0x0F) > 9) || regs8[FLAG_AF]) && (op_result = regs8[REG_AL] op1 6, set_CF(regs8[FLAG_CF] || (regs8[REG_AL] op2 scratch2_uint))), \
|
pascal@20279
|
8 - set_CF((((mask & 1 ? scratch2_uint : regs8[REG_AL]) & mask) > min) || regs8[FLAG_CF]) && (op_result = regs8[REG_AL] op1 0x60)
|
pascal@20279
|
9 +#define DAA_DAS(op1,op2) \
|
pascal@20279
|
10 +set_AF((((scratch_uchar = regs8[REG_AL]) & 0x0F) > 9) || regs8[FLAG_AF]) && (op_result = (regs8[REG_AL] op1 6), set_CF(regs8[FLAG_CF] || (regs8[REG_AL] op2 scratch_uchar))), \
|
pascal@20279
|
11 +set_CF((regs8[REG_AL] > 0x9f) || regs8[FLAG_CF]) && (op_result = (regs8[REG_AL] op1 0x60))
|
pascal@20279
|
12 #define ADC_SBB_MACRO(a) OP(a##= regs8[FLAG_CF] +), \
|
pascal@20279
|
13 set_CF(regs8[FLAG_CF] && (op_result == op_dest) || (a op_result < a(int)op_dest)), \
|
pascal@20279
|
14 set_AF_OF_arith()
|
pascal@20279
|
15 @@ -451,7 +452,6 @@
|
pascal@20279
|
16 OPCODE 12: // ROL|ROR|RCL|RCR|SHL|SHR|???|SAR reg/mem, 1/CL/imm (80186)
|
pascal@20279
|
17 scratch2_uint = SIGN_OF(mem[rm_addr]),
|
pascal@20279
|
18 scratch_uint = extra ? // xxx reg/mem, imm
|
pascal@20279
|
19 - ++reg_ip,
|
pascal@20279
|
20 (char)i_data1
|
pascal@20279
|
21 : // xxx reg/mem, CL
|
pascal@20279
|
22 i_d
|
pascal@20279
|
23 @@ -468,7 +468,7 @@
|
pascal@20279
|
24 else // Rotate/shift left operations
|
pascal@20279
|
25 R_M_OP(mem[rm_addr], <<=, scratch_uint);
|
pascal@20279
|
26 if (i_reg > 3) // Shift operations
|
pascal@20279
|
27 - set_opcode(0x10); // Decode like ADC
|
pascal@20279
|
28 + set_flags_type = FLAGS_UPDATE_SZP; // Shift instructions affect SZP
|
pascal@20279
|
29 if (i_reg > 4) // SHR or SAR
|
pascal@20279
|
30 set_CF(op_dest >> (scratch_uint - 1) & 1);
|
pascal@20279
|
31 }
|
pascal@20279
|
32 @@ -605,7 +605,7 @@
|
pascal@20279
|
33 rep_override_en && rep_override_en++
|
pascal@20279
|
34 OPCODE 28: // DAA/DAS
|
pascal@20279
|
35 i_w = 0;
|
pascal@20279
|
36 - extra ? DAA_DAS(-=, >=, 0xFF, 0x99) : DAA_DAS(+=, <, 0xF0, 0x90) // extra = 0 for DAA, 1 for DAS
|
pascal@20279
|
37 + if (extra) DAA_DAS(-=, >); else DAA_DAS(+=, <)
|
pascal@20279
|
38 OPCODE 29: // AAA/AAS
|
pascal@20279
|
39 op_result = AAA_AAS(extra - 1)
|
pascal@20279
|
40 OPCODE 30: // CBW
|