--- np2/i286x/i286x.cpp 2003/10/17 07:17:20 1.2 +++ np2/i286x/i286x.cpp 2003/12/09 15:49:14 1.8 @@ -1,5 +1,5 @@ #include "compiler.h" -#include "i286.h" +#include "cpucore.h" #include "i286x.h" #include "i286xadr.h" #include "i286xs.h" @@ -15,7 +15,7 @@ #include "dmap.h" - I286REG i286reg; + I286CORE i286core; const BYTE iflags[256] = { // Z_FLAG, S_FLAG, P_FLAG 0x44, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00, @@ -52,29 +52,34 @@ const BYTE iflags[256] = { // Z_FLAG 0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84}; -void i286_reset(void) { +void i286x_initialize(void) { - i286xadr_init(); // 毎回通すのはどうか… - v30init(); // 毎回通すのはどうか… - ZeroMemory(&i286reg, sizeof(i286reg)); + i286xadr_init(); + v30xinit(); +} + +void i286x_reset(void) { + + ZeroMemory(&i286core.s, sizeof(i286core.s)); I286_CS = 0x1fc0; CS_BASE = 0x1fc00; + i286core.s.adrsmask = 0xfffff; } -LABEL void i286_resetprefetch(void) { +LABEL void i286x_resetprefetch(void) { __asm { pushad movzx esi, I286_IP RESET_XPREFETCH - mov dword ptr (i286reg.prefetchque), ebx + mov dword ptr (i286core.s.prefetchque), ebx popad ret } } -LABEL void __fastcall i286_interrupt(BYTE vect) { +LABEL void __fastcall i286x_interrupt(BYTE vect) { __asm { pushad @@ -84,7 +89,7 @@ LABEL void __fastcall i286_interrupt(BYT sub bx, 2 // hlt.. - cmp byte ptr (i286reg.prefetchque), 0f4h // hlt + cmp byte ptr (i286core.s.prefetchque), 0f4h // hlt jne short nonhlt inc I286_IP nonhlt: mov edi, SS_BASE @@ -116,7 +121,7 @@ nonhlt: mov edi, SS_BASE shl eax, 4 // make segreg mov CS_BASE, eax RESET_XPREFETCH - mov dword ptr (i286reg.prefetchque), ebx + mov dword ptr (i286core.s.prefetchque), ebx popad ret @@ -164,11 +169,11 @@ LABEL void __fastcall i286x_localint(voi -LABEL void i286(void) { +LABEL void i286x(void) { __asm { pushad - mov ebx, dword ptr (i286reg.prefetchque) + mov ebx, dword ptr (i286core.s.prefetchque) movzx esi, I286_IP cmp I286_TRAP, 0 @@ -178,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 (i286reg.prefetchque), ebx + mov dword ptr (i286core.s.prefetchque), ebx mov I286_IP, si popad ret @@ -189,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 (i286reg.prefetchque), ebx + mov dword ptr (i286core.s.prefetchque), ebx mov I286_IP, si popad ret @@ -203,7 +208,7 @@ i286_trapping: movzx eax, bl je i286notrap mov ecx, 1 call i286x_localint -i286notrap: mov dword ptr (i286reg.prefetchque), ebx +i286notrap: mov dword ptr (i286core.s.prefetchque), ebx mov I286_IP, si popad ret @@ -212,11 +217,11 @@ i286notrap: mov dword ptr (i286reg.pre -LABEL void i286_step(void) { +LABEL void i286x_step(void) { __asm { pushad - mov ebx, dword ptr (i286reg.prefetchque) + mov ebx, dword ptr (i286core.s.prefetchque) movzx esi, I286_IP movzx eax, bl @@ -227,7 +232,7 @@ LABEL void i286_step(void) { mov ecx, 1 call i286x_localint nexts: - mov dword ptr (i286reg.prefetchque), ebx + mov dword ptr (i286core.s.prefetchque), ebx mov I286_IP, si call dmap_i286 @@ -242,7 +247,7 @@ nexts: LABEL void removeprefix(void) { __asm { - mov i286reg.prefix, 0 + mov i286core.s.prefix, 0 mov eax, DS_BASE mov DS_FIX, eax mov eax, SS_BASE @@ -571,14 +576,16 @@ I286 pop_ss(void) { // 17: pop ss shl eax, 4 // make segreg mov SS_BASE, eax mov SS_FIX, eax - cmp i286reg.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 } } @@ -2412,7 +2419,7 @@ I286 mov_seg_ea(void) { // 8E: mov segsetr:ret align 16 - setss: cmp i286reg.prefix, 0 // 00/05/13 + setss: cmp i286core.s.prefix, 0 // 00/05/13 je noprefix pop eax call eax // eax<-offset removeprefix @@ -2660,7 +2667,22 @@ I286 _popf(void) { // 9D: popf and ah, 3 cmp ah, 3 sete I286_TRAP - I286IRQCHECKTERM + + je irqcheck // fast_intr + test ah, 2 + 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 } } @@ -3574,7 +3596,23 @@ I286 _iret(void) { // CF: iret cmp ah, 3 sete I286_TRAP RESET_XPREFETCH - I286IRQCHECKTERM + + cmp I286_TRAP, 0 // fast_intr + jne irqcheck + test I286_FLAG, I_FLAG + 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 } } @@ -3889,7 +3927,7 @@ I286 in_al_data8(void) { // E4: in I286CLOCK(5) lea eax, [esi + 2] add eax, CS_BASE - mov i286reg.inport, eax + mov i286core.s.inport, eax movzx ecx, bh #if 1 call iocore_inp8 @@ -3897,7 +3935,7 @@ I286 in_al_data8(void) { // E4: in call i286_in #endif mov I286_AL, al - mov i286reg.inport, 0 + mov i286core.s.inport, 0 GET_NEXTPRE2 ret } @@ -4084,7 +4122,7 @@ I286 _repe(void) { // F3: repe I286 _hlt(void) { // F4: hlt __asm { - mov nevent.remainclock, -1 + mov I286_REMCLOCK, -1 ret } } @@ -4157,14 +4195,28 @@ 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 i286reg.prefix, 0 // ver0.26 00/10/08 - jne prefix_exist // 前方分岐ジャンプなので。 -noprefix: movzx eax, bl - call i286op[eax*4] + jne nextopandexit // fast_intr + cmp pic.ext_irq, 0 + 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