From e4946e8b850628cc032739bdd29c679f9f8c0fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 10 Nov 2013 16:22:33 +0000 Subject: [PATCH] [NTVDM] Instead of reassembling each time the very same common stub code for each interrupt, do it once, and then assemble just a little part for each interrupt and jump to the common stub. Now the 4DOS Ctrl-C exception bug changes, but I have an idea what's happening in there... svn path=/branches/ntvdm/; revision=60917 --- subsystems/ntvdm/int32.c | 44 +++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/subsystems/ntvdm/int32.c b/subsystems/ntvdm/int32.c index 9fcf573f7fe..4212709806f 100644 --- a/subsystems/ntvdm/int32.c +++ b/subsystems/ntvdm/int32.c @@ -128,25 +128,16 @@ VOID WINAPI Int32Dispatch(LPWORD Stack) VOID WINAPI InitializeInt32(WORD BiosSegment) { - USHORT i; - WORD Offset = 0; - LPDWORD IntVecTable = (LPDWORD)BaseAddress; - LPBYTE BiosCode = (LPBYTE)SEG_OFF_TO_PTR(BiosSegment, 0); + LPBYTE BiosCode = (LPBYTE)SEG_OFF_TO_PTR(BiosSegment, 0); - /* Generate ISR stubs and fill the IVT */ - for (i = 0x00; i <= 0xFF; i++) + USHORT i; + WORD CommonStub, BopSeqOffset, Offset; + + CommonStub = Offset = 0x00; + + /* Write the common stub code */ { - IntVecTable[i] = MAKELONG(Offset, BiosSegment); - - BiosCode[Offset++] = 0xFA; // cli - - BiosCode[Offset++] = 0x6A; // push i - BiosCode[Offset++] = (UCHAR)i; - - BiosCode[Offset++] = 0x6A; // push 0 - BiosCode[Offset++] = 0x00; - // BOP_SEQ: BiosCode[Offset++] = 0xF8; // clc @@ -173,6 +164,27 @@ VOID WINAPI InitializeInt32(WORD BiosSegment) BiosCode[Offset++] = 0xCF; // iret } + + /* Generate ISR stubs and fill the IVT */ + for (i = 0x00; i <= 0xFF; i++) + { + IntVecTable[i] = MAKELONG(Offset, BiosSegment); + + BiosCode[Offset++] = 0xFA; // cli + + BiosCode[Offset++] = 0x6A; // push i + BiosCode[Offset++] = (UCHAR)i; + + BiosCode[Offset++] = 0x6A; // push 0 + BiosCode[Offset++] = 0x00; + + BopSeqOffset = CommonStub - Offset - 3; + + BiosCode[Offset+0] = 0xE9; // jmp near BOP_SEQ + BiosCode[Offset+1] = LOBYTE(BopSeqOffset); + BiosCode[Offset+2] = HIBYTE(BopSeqOffset); + Offset+=3; + } } VOID WINAPI RegisterInt32(BYTE IntNumber, EMULATOR_INT32_PROC IntHandler)