--- np2/i286x/i286x.cpp 2003/10/16 17:57:25 1.1 +++ np2/i286x/i286x.cpp 2003/12/04 06:41:23 1.6 @@ -15,11 +15,7 @@ #include "dmap.h" - I286REGS i286r; - I286STAT i286s; - I286DTR GDTR; - I286DTR IDTR; - UINT16 MSW; + I286CORE i286core; const BYTE iflags[256] = { // Z_FLAG, S_FLAG, P_FLAG 0x44, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00, @@ -56,17 +52,18 @@ const BYTE iflags[256] = { // Z_FLAG 0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84}; +void i286_initialize(void) { + + i286xadr_init(); + v30init(); +} + void i286_reset(void) { - i286xadr_init(); // 毎回通すのはどうか… - v30init(); // 毎回通すのはどうか… - ZeroMemory(&i286r, sizeof(i286r)); - ZeroMemory(&i286s, sizeof(i286s)); + ZeroMemory(&i286core.s, sizeof(i286core.s)); I286_CS = 0x1fc0; CS_BASE = 0x1fc00; - ZeroMemory(&GDTR, sizeof(GDTR)); - ZeroMemory(&IDTR, sizeof(IDTR)); - MSW = 0; + i286core.s.adrsmask = 0xfffff; } @@ -76,7 +73,7 @@ LABEL void i286_resetprefetch(void) { pushad movzx esi, I286_IP RESET_XPREFETCH - mov dword ptr (i286s.prefetchque), ebx + mov dword ptr (i286core.s.prefetchque), ebx popad ret } @@ -92,7 +89,7 @@ LABEL void __fastcall i286_interrupt(BYT sub bx, 2 // hlt.. - cmp byte ptr (i286s.prefetchque), 0f4h // hlt + cmp byte ptr (i286core.s.prefetchque), 0f4h // hlt jne short nonhlt inc I286_IP nonhlt: mov edi, SS_BASE @@ -124,7 +121,7 @@ nonhlt: mov edi, SS_BASE shl eax, 4 // make segreg mov CS_BASE, eax RESET_XPREFETCH - mov dword ptr (i286s.prefetchque), ebx + mov dword ptr (i286core.s.prefetchque), ebx popad ret @@ -176,7 +173,7 @@ LABEL void i286(void) { __asm { pushad - mov ebx, dword ptr (i286s.prefetchque) + mov ebx, dword ptr (i286core.s.prefetchque) movzx esi, I286_IP cmp I286_TRAP, 0 @@ -186,9 +183,9 @@ LABEL void i286(void) { i286_mnlp: movzx eax, bl call i286op[eax*4] - cmp nevent.remainclock, 0 + cmp I286_REMCLOCK, 0 jg i286_mnlp - mov dword ptr (i286s.prefetchque), ebx + mov dword ptr (i286core.s.prefetchque), ebx mov I286_IP, si popad ret @@ -197,9 +194,9 @@ i286_mnlp: movzx eax, bl i286_dma_mnlp: movzx eax, bl call i286op[eax*4] call dmap_i286 - cmp nevent.remainclock, 0 + cmp I286_REMCLOCK, 0 jg i286_dma_mnlp - mov dword ptr (i286s.prefetchque), ebx + mov dword ptr (i286core.s.prefetchque), ebx mov I286_IP, si popad ret @@ -211,7 +208,7 @@ i286_trapping: movzx eax, bl je i286notrap mov ecx, 1 call i286x_localint -i286notrap: mov dword ptr (i286s.prefetchque), ebx +i286notrap: mov dword ptr (i286core.s.prefetchque), ebx mov I286_IP, si popad ret @@ -224,7 +221,7 @@ LABEL void i286_step(void) { __asm { pushad - mov ebx, dword ptr (i286s.prefetchque) + mov ebx, dword ptr (i286core.s.prefetchque) movzx esi, I286_IP movzx eax, bl @@ -235,7 +232,7 @@ LABEL void i286_step(void) { mov ecx, 1 call i286x_localint nexts: - mov dword ptr (i286s.prefetchque), ebx + mov dword ptr (i286core.s.prefetchque), ebx mov I286_IP, si call dmap_i286 @@ -250,7 +247,7 @@ nexts: LABEL void removeprefix(void) { __asm { - mov i286s.prefix, 0 + mov i286core.s.prefix, 0 mov eax, DS_BASE mov DS_FIX, eax mov eax, SS_BASE @@ -579,14 +576,16 @@ I286 pop_ss(void) { // 17: pop ss shl eax, 4 // make segreg mov SS_BASE, eax mov SS_FIX, eax - cmp i286s.prefix, 0 // 00/06/24 - je noprefix - call removeprefix - pop eax + cmp i286core.s.prefix, 0 // 00/06/24 + jne prefix_exist noprefix: movzx ebp, bh GET_NEXTPRE1 jmp i286op[ebp*4] + +prefix_exist: pop eax // eax<-offset removeprefix + call eax + jmp noprefix } } @@ -2420,7 +2419,7 @@ I286 mov_seg_ea(void) { // 8E: mov segsetr:ret align 16 - setss: cmp i286s.prefix, 0 // 00/05/13 + setss: cmp i286core.s.prefix, 0 // 00/05/13 je noprefix pop eax call eax // eax<-offset removeprefix @@ -2668,7 +2667,21 @@ I286 _popf(void) { // 9D: popf and ah, 3 cmp ah, 3 sete I286_TRAP - I286IRQCHECKTERM + + test ah, 2 // fast_intr + je nextop + cmp pic.ext_irq, 0 + jne nextop + mov al, pic.pi[0].imr + mov ah, pic.pi[1].imr + not ax + test al, pic.pi[0].irr + jne irqcheck + test al, pic.pi[1].irr + jne irqcheck +nextop: ret + +irqcheck: I286IRQCHECKTERM } } @@ -3582,7 +3595,21 @@ I286 _iret(void) { // CF: iret cmp ah, 3 sete I286_TRAP RESET_XPREFETCH - I286IRQCHECKTERM + + test I286_FLAG, I_FLAG // fast_intr + je nextop + cmp pic.ext_irq, 0 + jne nextop + mov al, pic.pi[0].imr + mov ah, pic.pi[1].imr + not ax + test al, pic.pi[0].irr + jne irqcheck + test al, pic.pi[1].irr + jne irqcheck +nextop: ret + +irqcheck: I286IRQCHECKTERM } } @@ -3897,7 +3924,7 @@ I286 in_al_data8(void) { // E4: in I286CLOCK(5) lea eax, [esi + 2] add eax, CS_BASE - mov i286s.inport, eax + mov i286core.s.inport, eax movzx ecx, bh #if 1 call iocore_inp8 @@ -3905,7 +3932,7 @@ I286 in_al_data8(void) { // E4: in call i286_in #endif mov I286_AL, al - mov i286s.inport, 0 + mov i286core.s.inport, 0 GET_NEXTPRE2 ret } @@ -3917,7 +3944,6 @@ I286 in_ax_data8(void) { // E5: in I286CLOCK(5) lea eax, [esi + 2] add eax, CS_BASE - mov i286s.inport, eax movzx ecx, bh call iocore_inp16 mov I286_AX, ax @@ -4093,7 +4119,7 @@ I286 _repe(void) { // F3: repe I286 _hlt(void) { // F4: hlt __asm { - mov nevent.remainclock, -1 + mov I286_REMCLOCK, -1 ret } } @@ -4166,14 +4192,27 @@ I286 _sti(void) { // FB: sti __asm { GET_NEXTPRE1 I286CLOCK(2) - or I286_FLAG, I_FLAG + cmp i286core.s.prefix, 0 // ver0.26 00/10/08 + jne prefix_exist // 前方分岐ジャンプなので。 + noprefix: + movzx ebp, bl + bts I286_FLAG, 9 + jne jmp_nextop test I286_FLAG, T_FLAG setne I286_TRAP - cmp i286s.prefix, 0 // ver0.26 00/10/08 - jne prefix_exist // 前方分岐ジャンプなので。 -noprefix: movzx eax, bl - call i286op[eax*4] + cmp pic.ext_irq, 0 // fast_intr + jne jmp_nextop + mov al, pic.pi[0].imr + mov ah, pic.pi[1].imr + not ax + test al, pic.pi[0].irr + jne nextopandexit + test al, pic.pi[1].irr + jne nextopandexit +jmp_nextop: jmp i286op[ebp*4] + +nextopandexit: call i286op[ebp*4] I286IRQCHECKTERM prefix_exist: pop eax // eax<-offset removeprefix