--- np2/i286c/i286c_mn.c 2003/12/08 00:55:31 1.22 +++ np2/i286c/i286c_mn.c 2004/02/21 17:52:04 1.35 @@ -1,7 +1,6 @@ #include "compiler.h" #include "cpucore.h" #include "i286c.h" -#include "memory.h" #include "pccore.h" #include "iocore.h" #include "bios.h" @@ -28,7 +27,6 @@ I286FN _reserved(void) { - I286_WORKCLOCK(23); // ToDo INT_NUM(6, I286_IP - 1); } @@ -149,8 +147,11 @@ I286FN _push_es(void) { // 06: pus I286FN _pop_es(void) { // 07: pop es - REGPOP(I286_ES, 5) - ES_BASE = (UINT32)I286_ES << 4; + UINT tmp; + + REGPOP(tmp, 5) + I286_ES = tmp; + ES_BASE = SEGSELECT(tmp); } I286FN _or_ea_r8(void) { // 08: or EA, REG8 @@ -383,8 +384,11 @@ I286FN _push_ss(void) { // 16: pus I286FN _pop_ss(void) { // 17: pop ss - REGPOP(I286_SS, 5) - SS_BASE = I286_SS << 4; + UINT tmp; + + REGPOP(tmp, 5) + I286_SS = tmp; + SS_BASE = SEGSELECT(tmp); SS_FIX = SS_BASE; NEXT_OPCODE } @@ -506,8 +510,11 @@ I286FN _push_ds(void) { // 1e: pus I286FN _pop_ds(void) { // 1f: pop ds - REGPOP(I286_DS, 5) - DS_BASE = I286_DS << 4; + UINT tmp; + + REGPOP(tmp, 5) + I286_DS = tmp; + DS_BASE = SEGSELECT(tmp); DS_FIX = DS_BASE; } @@ -1660,6 +1667,7 @@ I286FN _mov_seg_ea(void) { // 8E: mo UINT op; UINT tmp; + UINT32 base; UINT16 ipbak; ipbak = I286_IP; @@ -1672,23 +1680,24 @@ I286FN _mov_seg_ea(void) { // 8E: mo I286_WORKCLOCK(5); tmp = i286_memoryread_w(CALC_EA(op)); } + base = SEGSELECT(tmp); switch(op & 0x18) { case 0x00: // es I286_ES = (UINT16)tmp; - ES_BASE = tmp << 4; + ES_BASE = base; break; case 0x10: // ss I286_SS = (UINT16)tmp; - SS_BASE = tmp << 4; - SS_FIX = SS_BASE; + SS_BASE = base; + SS_FIX = base; NEXT_OPCODE break; case 0x18: // ds I286_DS = (UINT16)tmp; - DS_BASE = tmp << 4; - DS_FIX = DS_BASE; + DS_BASE = base; + DS_FIX = base; break; default: // cs @@ -1795,7 +1804,7 @@ I286FN _call_far(void) { // 9A: call REGPUSH0(I286_CS) GET_PCWORD(newip) GET_PCWORD(I286_CS) - CS_BASE = I286_CS << 4; + CS_BASE = SEGSELECT(I286_CS); REGPUSH0(I286_IP) I286_IP = newip; } @@ -2103,7 +2112,7 @@ I286FN _les_r16_ea(void) { // C4: le ad = GET_EA(op, &seg); *(REG16_B53(op)) = i286_memoryread_w(seg + ad); I286_ES = i286_memoryread_w(seg + LOW16(ad + 2)); - ES_BASE = I286_ES << 4; + ES_BASE = SEGSELECT(I286_ES); } else { INT_NUM(6, I286_IP - 2); @@ -2122,7 +2131,7 @@ I286FN _lds_r16_ea(void) { // C5: ld ad = GET_EA(op, &seg); *(REG16_B53(op)) = i286_memoryread_w(seg + ad); I286_DS = i286_memoryread_w(seg + LOW16(ad + 2)); - DS_BASE = I286_DS << 4; + DS_BASE = SEGSELECT(I286_DS); DS_FIX = DS_BASE; } else { @@ -2233,7 +2242,7 @@ I286FN _ret_far_data16(void) { // CA: REGPOP0(I286_IP) REGPOP0(I286_CS) I286_SP += ad; - CS_BASE = I286_CS << 4; + CS_BASE = SEGSELECT(I286_CS); } I286FN _ret_far(void) { // CB: ret far @@ -2241,12 +2250,12 @@ I286FN _ret_far(void) { // CB: ret I286_WORKCLOCK(15); REGPOP0(I286_IP) REGPOP0(I286_CS) - CS_BASE = I286_CS << 4; + CS_BASE = SEGSELECT(I286_CS); } I286FN _int_03(void) { // CC: int 3 - I286_WORKCLOCK(23); + I286_WORKCLOCK(3); INT_NUM(3, I286_IP); } @@ -2254,8 +2263,14 @@ I286FN _int_data8(void) { // CD: int UINT vect; - I286_WORKCLOCK(23); + I286_WORKCLOCK(3); GET_PCBYTE(vect) +#if 0 // defined(TRACE) + if ((vect >= 0xa0) && (vect < 0xb0)) { +extern void lio_look(UINT vect); + lio_look(vect); + } +#endif INT_NUM(vect, I286_IP); } @@ -2263,7 +2278,6 @@ I286FN _into(void) { // CE: into I286_WORKCLOCK(4); if (I286_OV) { - I286_WORKCLOCK(24 - 4); INT_NUM(4, I286_IP); } } @@ -2272,7 +2286,6 @@ I286FN _iret(void) { // CF: iret UINT flag; - extirq_pop(); REGPOP0(I286_IP) REGPOP0(I286_CS) REGPOP0(flag) @@ -2280,6 +2293,7 @@ I286FN _iret(void) { // CF: iret I286_FLAG = flag & (0xfff ^ O_FLAG); I286_TRAP = ((flag & 0x300) == 0x300); CS_BASE = I286_CS << 4; +// CS_BASE = SEGSELECT(I286_CS); I286_WORKCLOCK(31); #if defined(INTR_FAST) if ((I286_TRAP) || ((flag & I_FLAG) && (PICEXISTINTR))) { @@ -2341,7 +2355,7 @@ I286FN _shift_ea8_cl(void) { // D2: sh BYTE *out; UINT op; UINT32 madr; - BYTE cl; + REG8 cl; GET_PCBYTE(op) if (op >= 0xc0) { @@ -2369,7 +2383,7 @@ I286FN _shift_ea16_cl(void) { // D3: s UINT16 *out; UINT op; UINT32 madr; - BYTE cl; + REG8 cl; GET_PCBYTE(op) if (op >= 0xc0) { @@ -2533,8 +2547,8 @@ I286FN _jmp_far(void) { // EA: jmp I286_WORKCLOCK(11); GET_PCWORD(ad); GET_PCWORD(I286_CS); - CS_BASE = I286_CS << 4; I286_IP = ad; + CS_BASE = SEGSELECT(I286_CS); } I286FN _jmp_short(void) { // EB: jmp short