diff --git a/bld/causeway/asm/api.asm b/bld/causeway/asm/api.asm index 58ce718b56..9266fa940d 100644 --- a/bld/causeway/asm/api.asm +++ b/bld/causeway/asm/api.asm @@ -158,7 +158,8 @@ api1_GotCall: movzx ebp,bp mov esi,Int_Flags16 api1_32Bit0: - and BYTE PTR ss:[ebp+esi],not EFLAG_CF ;clear carry. + ;clear CF (carry). + and BYTE PTR ss:[ebp+esi],not EFLAG_CF cld ;Default direction. test WORD PTR ss:[ebp+esi],EFLAG_IF ;Were interrupts enabled? jz api1_NoInts @@ -847,7 +848,8 @@ medUse32Bit8: medUse16Bit8: mov ax,ss:[ebp+ebx] - and ax,NOT (EFLAG_IF or EFLAG_TF) ;clear Trap and INT flag. + ;clear IF & TF (Trap and INT). + and ax,NOT (EFLAG_IF or EFLAG_TF) mov es:RealRegsStruc.Real_Flags[edi],ax ; explicitly set flags on DPMI 300h call assume ds:_apiCode @@ -886,8 +888,10 @@ api15_Use32Bit8: mov ebx,Int_Flags32 api15_Use16Bit8: mov ax,ss:[ebp+ebx] - and ax,EFLAG_IF or EFLAG_DF ;retain IF & DF. - and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF) ;lose IF & DF. + ;retain IF & DF. + and ax,EFLAG_IF or EFLAG_DF + ;clear IF & DF. + and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF) or es:RealRegsStruc.Real_Flags[edi],ax ret cwAPI_IntXX endp @@ -961,8 +965,10 @@ api16_Use32Bit8: mov ebx,Int_Flags32 api16_Use16Bit8: mov ax,ss:[ebp+ebx] - and ax,EFLAG_IF or EFLAG_DF ;retain IF & DF. - and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF) ;lose IF & DF. + ;retain IF & DF. + and ax,EFLAG_IF or EFLAG_DF + ;clear IF & DF. + and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF) or es:RealRegsStruc.Real_Flags[edi],ax ret cwAPI_FarCallReal endp diff --git a/bld/causeway/asm/cw32.asm b/bld/causeway/asm/cw32.asm index 86df6b5702..be56645d04 100644 --- a/bld/causeway/asm/cw32.asm +++ b/bld/causeway/asm/cw32.asm @@ -2164,8 +2164,10 @@ nosse: push edx ;ESP pushfd ;EFlags pop eax - and ax,NOT (EFLAG_NT or EFLAG_IOPL) ;clear NT & IOPL. - or ax,EFLAG_IOPL ;force IOPL 3. + ;clear NT & IOPL. + and ax,NOT (EFLAG_NT or EFLAG_IOPL) + ;force IOPL 3. + or ax,EFLAG_IOPL push eax popfd push eax @@ -5108,7 +5110,7 @@ MakeDesc endp ; ;On Entry:- ; -;ES:DI - Descriptor entry to use. +;ES:EDI - Descriptor entry to use. ;ESI - Linear base to set. ;ECX - limit in bytes. ;AL - Code size bit. diff --git a/bld/causeway/asm/int21h.asm b/bld/causeway/asm/int21h.asm index cd44015e50..b6a83e5e12 100644 --- a/bld/causeway/asm/int21h.asm +++ b/bld/causeway/asm/int21h.asm @@ -123,7 +123,8 @@ Int21h proc near mov esi,Int_Flags16 int211_32Bit0: add esi,ebp - and BYTE PTR ss:[esi],not EFLAG_CF + ;clear CF (carry) + and BYTE PTR ss:[esi],NOT EFLAG_CF cld ;Default direction. test WORD PTR ss:[esi],EFLAG_IF ;Were interrupts enabled? jz int211_NoInts @@ -1109,7 +1110,7 @@ int2121_Ef15: ; pop ax int2121_Ef13: - and ax,EFLAG_CF + and al,EFLAG_CF call Int21hAL2Carry ret Int21hExecFile endp diff --git a/bld/causeway/asm/interrup.asm b/bld/causeway/asm/interrup.asm index b0c4a111c7..1428609d9b 100644 --- a/bld/causeway/asm/interrup.asm +++ b/bld/causeway/asm/interrup.asm @@ -1078,7 +1078,8 @@ inter15_Int: push ax xor eax,eax mov ax,[ebx+(4+4+4+4+4)+IFrame16.i16_flags] ;get flags again. - and ax,NOT (EFLAG_IF or EFLAG_TF) ;lose IF & TF + ;clear IF & TF + and ax,NOT (EFLAG_IF or EFLAG_TF) push eax ;int handler flags. jmp inter15_i2Use0 ; @@ -1094,7 +1095,8 @@ inter15_i2Use32: mov eax,[ebx+(4+4+4+4+4)+IFrame.i_eip] ;get IP push eax mov eax,[ebx+(4+4+4+4+4)+IFrame.i_eflags] ;get flags again. - and ax,NOT (EFLAG_IF or EFLAG_TF) ;lose IF & TF + ;clear IF & TF + and ax,NOT (EFLAG_IF or EFLAG_TF) push eax ;int handler flags. ; inter15_i2Use0: @@ -1230,6 +1232,7 @@ IntDispatch proc near push ds mov ax,DpmiEmuDS mov ds,ax + ;clear IF & TF. and w[ExceptionFlags],NOT (EFLAG_IF or EFLAG_TF) mov esi,ExceptionIndex ;Get the exception number. add esi,esi ;*2 @@ -1302,8 +1305,10 @@ inter17_Resume: ; movzx ebx,bx lss sp,d[ebx+(4+4+4+4)+IFrame16.i16_sp] ;get old stack address. - and w[ebx+(4+4+4+4)+IFrame16.i16_flags],EFLAG_IF or EFLAG_TF or EFLAG_DF ;retain IF & TF & DF. - and w[ebx+(4+4+4)],NOT (EFLAG_IF or EFLAG_TF or EFLAG_DF) ;lose IF & TF & DF. + ;retain IF & TF & DF. + and w[ebx+(4+4+4+4)+IFrame16.i16_flags],EFLAG_IF or EFLAG_TF or EFLAG_DF + ;clear IF & TF & DF. + and w[ebx+(4+4+4)],NOT (EFLAG_IF or EFLAG_TF or EFLAG_DF) mov ax,[ebx+(4+4+4)] or ax,[ebx+(4+4+4+4)+IFrame16.i16_flags] push ax ;EFlags. @@ -1330,8 +1335,10 @@ inter17_Resume: ; inter17_Use32: lss esp,f[ebx+(4+4+4+4)+IFrame.i_esp] ;get old stack address. - and w[ebx+(4+4+4+4)+IFrame.i_eflags],EFLAG_IF or EFLAG_TF or EFLAG_DF ;retain IF & TF & DF. - and w[ebx+(4+4+4)],NOT (EFLAG_IF or EFLAG_TF or EFLAG_DF) ;lose IF & TF & DF. + ;retain IF & TF & DF. + and w[ebx+(4+4+4+4)+IFrame.i_eflags],EFLAG_IF or EFLAG_TF or EFLAG_DF + ;clear IF & TF & DF. + and w[ebx+(4+4+4)],NOT (EFLAG_IF or EFLAG_TF or EFLAG_DF) mov eax,[ebx+(4+4+4)] or eax,[ebx+(4+4+4+4)+IFrame.i_eflags] push eax ;EFlags. @@ -1542,7 +1549,8 @@ inter18_c2: ;Now pass control to the INT simulator. ; mov eax,[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)] - and eax,0ffffh and NOT (EFLAG_IF or EFLAG_TF or EFLAG_DF) + ;clear IF & TF & DF. + and ax,NOT (EFLAG_IF or EFLAG_TF or EFLAG_DF) push eax popfd mov ebx,edx @@ -1565,12 +1573,14 @@ inter18_NoCall: ;Update the flags. ; mov ax,es:RealRegsStruc.Real_Flags[edi] - and ax,NOT (EFLAG_NT or EFLAG_IOPL or EFLAG_IF or EFLAG_TF or EFLAG_DF) ;lose IF & TF & DF & NT & IOPL. + ;clear IF & TF & DF & NT & IOPL. + and ax,NOT (EFLAG_NT or EFLAG_IOPL or EFLAG_IF or EFLAG_TF or EFLAG_DF) ; test BYTE PTR DpmiEmuSystemFlags,1 jz inter18_Use32Bit mov bx,[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4+4)+IFrame16.i16_flags] - and bx,EFLAG_NT or EFLAG_IOPL or EFLAG_IF or EFLAG_TF or EFLAG_DF ;retain IF & TF & DF & NT & IOPL. + ;retain IF & TF & DF & NT & IOPL. + and bx,EFLAG_NT or EFLAG_IOPL or EFLAG_IF or EFLAG_TF or EFLAG_DF or ax,bx mov [ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4+4)+IFrame16.i16_flags],ax popad @@ -1585,7 +1595,8 @@ inter18_NoCall: ; inter18_Use32Bit: mov bx,[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4+4)+IFrame.i_eflags] - and bx,EFLAG_NT or EFLAG_IOPL or EFLAG_IF or EFLAG_TF or EFLAG_DF ;retain IF & TF & DF & NT & IOPL. + ;retain IF & TF & DF & NT & IOPL. + and bx,EFLAG_NT or EFLAG_IOPL or EFLAG_IF or EFLAG_TF or EFLAG_DF or ax,bx mov [ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4+4)+IFrame.i_eflags],ax popad diff --git a/bld/causeway/asm/ldt.asm b/bld/causeway/asm/ldt.asm index 6b37e0bf8b..6ce81a6984 100644 --- a/bld/causeway/asm/ldt.asm +++ b/bld/causeway/asm/ldt.asm @@ -298,7 +298,7 @@ RawSetSelType proc near mov ax,KernalZero ;make LDT addresable. mov es,ax movzx esi,bx ;Get the selector. - GetDescIndex esi ;lose RPL & TI. + ClearDescTIRPL esi ;lose RPL & TI. add esi,MDTLinear ;offset into descriptor table. mov BYTE PTR es:[esi+5],cl and ch,11110000b @@ -337,7 +337,7 @@ RawSetSelLimit proc near mov ax,KernalZero ;make LDT addresable. mov es,ax movzx esi,bx ;Get the selector. - GetDescIndex esi ;lose RPL & TI. + ClearDescTIRPL esi ;lose RPL & TI. add esi,MDTLinear ;offset into descriptor table. shl ecx,16 ;cx:dx -> ecx mov cx,dx ;/ @@ -384,7 +384,7 @@ RawSetSelBase proc near mov ax,KernalZero ;make LDT addressable. mov es,ax movzx esi,bx ;Get the selector. - GetDescIndex esi ;lose RPL & TI. + ClearDescTIRPL esi ;lose RPL & TI. add esi,MDTLinear ;offset into descriptor table. mov es:[esi+4],cl ;base mid. mov es:[esi+7],ch ;base high. @@ -423,7 +423,7 @@ RawGetSelBase proc near mov ax,KernalZero ;make LDT addresable. mov es,ax movzx esi,bx ;Get the selector. - GetDescIndex esi ;lose RPL & TI. + ClearDescTIRPL esi ;lose RPL & TI. add esi,MDTLinear ;offset into descriptor table. mov cl,es:[esi+4] ;base mid. mov ch,es:[esi+7] ;base high. @@ -459,7 +459,7 @@ RawBPutDescriptor proc near mov ds,ax assume ds:_cwRaw movzx esi,bx ;Get the selector. - GetDescIndex esi ;lose RPL & TI. + ClearDescTIRPL esi ;lose RPL & TI. add esi,MDTLinear ;offset into descriptor table. test BYTE PTR RawSystemFlags,1 jz ldt8_Use32 @@ -511,7 +511,7 @@ RawBGetDescriptor proc near mov ds,ax assume ds:_cwRaw movzx esi,bx ;Get the selector. - GetDescIndex esi ;lose RPL & TI. + ClearDescTIRPL esi ;lose RPL & TI. add esi,MDTLinear ;offset into descriptor table. test BYTE PTR RawSystemFlags,1 jz ldt9_Use32 diff --git a/bld/causeway/asm/memory.asm b/bld/causeway/asm/memory.asm index 9da21760db..c2bf7c67c3 100644 --- a/bld/causeway/asm/memory.asm +++ b/bld/causeway/asm/memory.asm @@ -687,7 +687,7 @@ mem4_0: cmp edx,LinearBase jc mem4_1 cmp edx,LinearLimit jnc mem4_2 - and DWORD PTR es:[esi+ebx*4],not (PAGE_DIRTY or PAGE_ON_DISK) ;clear dirty & disk bits. + and DWORD PTR es:[esi+ebx*4],NOT (PAGE_DIRTY or PAGE_ON_DISK) ;clear dirty & disk bits. mem4_1: add edx,4096 inc ebx dec ecx @@ -1308,7 +1308,7 @@ mem9_l5: ; ;Get free disk space remaining. ; - mov dl,VMMName ;get drive letter for this media. + mov dl,VMMName ;get drive letter for this media. sub dl,'A' ;make it real. inc dl ;adjust for current type select. mov ah,36h ;get free space. @@ -1334,7 +1334,7 @@ mem9_l7: mov dx,ax ;/ pop eax add edx,eax - RoundDN edx,65536 + Round64kDN edx GetPageIndex edx pop ebp pop ebx @@ -1428,10 +1428,10 @@ ExtendLinearMemory proc near ;Try extending useing physical memory first. ; mem10_f0: - mov eax,LinearLimit ;get new entry number. - GetPageIndex eax ;page number. + mov eax,LinearLimit ;get new entry number. + GetPageIndex eax ;page number. mov LinearEntry,eax - shr eax,10 ;/1024 for page dir entry. + shr eax,10 ;/1024 for page dir entry. mov edi,PageDirLinear ;get page table address. mov eax,DWORD PTR es:[edi+eax*4] ;this page present? test eax,PAGE_PRESENT ;do we have a page table? @@ -1501,7 +1501,7 @@ mem10_Virtual: mul bx ;Get bytes available. shl edx,16 ;dx:ax -> edx mov dx,ax ;/ - RoundDN edx,65536 + Round64kDN edx add edx,SwapFileLength ;add existing size. mov eax,LinearLimit sub eax,LinearBase ;get current real memory. @@ -1616,7 +1616,7 @@ mem10_v4: add ecx,eax ;New extremity desired. cmp ecx,SwapFileLength jc mem10_Extended - RoundUP ecx,65536 + Round64kUP ecx push ecx mov dx,cx ;ecx ->cx:dx shr ecx,16 ;/ @@ -1888,7 +1888,7 @@ mem11_ok: ; mov eax,LinearEntry ;get new entry number. mov esi,1024*4096*1023 ;base of page alias's. - and DWORD PTR es:[esi+eax*4],NOT (PAGE_ACCESED or PAGE_DIRTY) ;clear accesed & dirty bits. + and DWORD PTR es:[esi+eax*4],NOT (PAGE_ACCESED or PAGE_DIRTY) ;clear accesed & dirty bits. call EmuCR3Flush ; mem11_NoRead: @@ -2409,7 +2409,7 @@ VirtualFault proc far call UnMapPhysical ;retrieve a physical page to use. pop eax jc mem18_Disk_Error ;This should only happen on disk errors. - shr eax,12 + GetPageIndex eax push LinearEntry mov LinearEntry,eax ;setup linear address we want to map. call MapPhysical ;map new page into faulting linear address space. @@ -2489,9 +2489,9 @@ mem19_1: ; push eax push ecx - dec cx ;lose our para. - shr cx,12 ;get number of 64k chunks. - inc cx ;+1 for base. + dec cx ;lose our para. + shr cx,12 ;get number of 64k chunks. + inc cx ;+1 for base. call RawGetDescriptors pop ecx pop ebx @@ -2502,16 +2502,16 @@ mem19_1: push ecx mov dx,KernalZero mov es,dx - movzx esi,bx ;get segment address. - shl esi,4 ;get linear address. - mov WORD PTR es:[esi],cx ;store block size. - dec WORD PTR es:[esi] ;lose our para. + movzx esi,bx ;get segment address. + shl esi,4 ;get linear address. + mov WORD PTR es:[esi],cx ;store block size. + dec WORD PTR es:[esi] ;lose our para. pop ecx ; ;Setup selectors. ; - dec cx ;lose our para. - inc bx ;/ + dec cx ;lose our para. + inc bx ;/ push ds pop es push eax @@ -2523,7 +2523,7 @@ mem19_2: push ecx push eax mov edi,offset RawSelBuffer - Round8UP edi + Round8UP edi ;allign pointer to 8 bytes movzx esi,bx shl esi,4 movzx ecx,cx @@ -2537,14 +2537,14 @@ mem19_2: pop ecx pop ebx pop eax - add eax,8 ;next selector. + add eax,8 ;next selector. add ebx,1000h ;update segment base. movzx ecx,cx sub ecx,1000h ;reduce segment size. - jns mem19_2 ;keep going till all done. + jns mem19_2 ;keep going till all done. ; - pop eax ;Get base segment again. - pop edx ;Get base selector again. + pop eax ;Get base segment again. + pop edx ;Get base selector again. clc jmp mem19_10 ; @@ -2600,12 +2600,12 @@ RawResDOSMemory proc near shl ecx,16 ;cx:dx -> ecx mov cx,dx ;/ mov esi,ecx - sub esi,16 ;back to our stuff. + sub esi,16 ;back to our stuff. pop dx pop bx mov ax,KernalZero mov es,ax - cmp bx,WORD PTR es:[esi] ;shrinking or expanding? + cmp bx,WORD PTR es:[esi] ;shrinking or expanding? jz mem20_8 jnc mem20_Expand ; @@ -2614,12 +2614,12 @@ mem20_Shrink: ; push ebx push edx - inc ebx ;include our para. + inc ebx ;include our para. push ds pop es mov edi,offset MemIntBuffer mov eax,esi - shr eax,4 ;get real mode segment. + shr eax,4 ;get real mode segment. mov RealRegsStruc.Real_EAX[edi],4a00h mov RealRegsStruc.Real_EBX[edi],ebx mov RealRegsStruc.Real_ES[edi],ax @@ -2632,7 +2632,7 @@ mem20_Shrink: test RealRegsStruc.Real_Flags[edi],EFLAG_CF pop edx pop ecx - jnz mem20_9 ;DOS failed it! + jnz mem20_9 ;DOS failed it! ; ;Lose any selectors that are no longer needed. ; @@ -2643,31 +2643,31 @@ mem20_Shrink: shl ecx,16 ;cx:dx -> ecx mov cx,dx ;/ mov esi,ecx - sub esi,16 ;back to our stuff. + sub esi,16 ;back to our stuff. pop edx pop ecx push ecx push edx mov ax,KernalZero mov es,ax - mov ax,WORD PTR es:[esi] ;get old size. - mov WORD PTR es:[esi],cx ;store new size. + mov ax,WORD PTR es:[esi] ;get old size. + mov WORD PTR es:[esi],cx ;store new size. shr ax,12 inc eax - mov ebx,eax ;need existing number. - shr cx,12 ;get 64k chunks. - inc ecx ;+ base. - sub ax,cx ;get number of selectors to lose. + mov ebx,eax ;need existing number. + shr cx,12 ;get 64k chunks. + inc ecx ;+ base. + sub ax,cx ;get number of selectors to lose. jz mem20_0 pop edx pop ecx push ecx push edx shl bx,3 - add dx,bx ;move to end of descriptors. + add dx,bx ;move to end of descriptors. movzx ecx,ax shl ax,3 - sub edx,eax ;reduce by number to lose. + sub edx,eax ;reduce by number to lose. mov ebx,edx mem20_1: push ebx @@ -2691,12 +2691,12 @@ mem20_0: shl ecx,16 ;cx:dx -> ecx mov cx,dx ;/ mov ebx,ecx - shr ebx,4 ;get real mode segment. + shr ebx,4 ;get real mode segment. pop edx pop ecx mov eax,edx -; shr ax,3 ;lose TI & RPL -; shr ax,3 ;get descriptor number. +; shr ax,3 ;lose TI & RPL +; shr ax,3 ;get descriptor number. push ds pop es ; @@ -2706,7 +2706,7 @@ mem20_2: push ecx push eax mov edi,offset RawSelBuffer - Round8UP edi + Round8UP edi ;allign pointer to 8 bytes movzx esi,bx shl esi,4 movzx ecx,cx @@ -2720,11 +2720,11 @@ mem20_2: pop ecx pop ebx pop eax - add eax,8 ;next selector. + add eax,8 ;next selector. add ebx,1000h ;update segment base. movzx ecx,cx sub ecx,1000h ;reduce segment size. - jns mem20_2 ;keep going till all done. + jns mem20_2 ;keep going till all done. ; mem20_8: clc @@ -2733,7 +2733,7 @@ mem20_8: mem20_Expand: ;Attempt to expand the memory block. ; - mov bx,WORD PTR es:[esi] ;return current length as maximum. + mov bx,WORD PTR es:[esi] ;return current length as maximum. mov ax,8 mem20_9: stc @@ -2814,12 +2814,12 @@ mem21_z3: mov cx,dx ;/ mov esi,ecx pop ebx - sub esi,16 ;back to our stuff. + sub esi,16 ;back to our stuff. mov eax,esi - shr eax,4 ;real mode paragraph address. + shr eax,4 ;real mode paragraph address. mov dx,KernalZero mov es,dx - mov cx,WORD PTR es:[esi] ;get block size. + mov cx,WORD PTR es:[esi] ;get block size. ; ;Release selectors. ; @@ -2831,10 +2831,10 @@ mem21_0: pop ecx pop ebx pop eax - add ebx,8 ;next descriptor. + add ebx,8 ;next descriptor. movzx ecx,cx sub ecx,1000h - jns mem21_0 ;release all selectors. + jns mem21_0 ;release all selectors. ; ;Release DOS memory block. ; @@ -2842,11 +2842,11 @@ mem21_0: pop es mov edi,offset MemIntBuffer mov RealRegsStruc.Real_EAX[edi],4900h ;release block. - mov RealRegsStruc.Real_ES[edi],ax ;block to release. + mov RealRegsStruc.Real_ES[edi],ax ;block to release. mov RealRegsStruc.Real_SS[edi],0 mov RealRegsStruc.Real_SP[edi],0 mov bl,21h - call EmuRawSimulateInt ;release it. + call EmuRawSimulateInt ;release it. mov eax,RealRegsStruc.Real_EAX[edi] test RealRegsStruc.Real_Flags[edi],EFLAG_CF clc diff --git a/bld/causeway/asm/raw_vcpi.asm b/bld/causeway/asm/raw_vcpi.asm index a34ad4f488..842b412532 100644 --- a/bld/causeway/asm/raw_vcpi.asm +++ b/bld/causeway/asm/raw_vcpi.asm @@ -1870,6 +1870,7 @@ rv29_Back: pop edi pop esi mov bx,[esp+(2+2+2+2)+(4+4+4+4+4+4+4+4)+(4+4+2)+2] + ;clear OF & DF & SF & ZF & AF & PF & CF and bx,NOT (EFLAG_OF or EFLAG_DF or EFLAG_SF or EFLAG_ZF or EFLAG_AF or EFLAG_PF or EFLAG_CF) or es:RealRegsStruc.Real_Flags[edi],bx ; @@ -2374,7 +2375,9 @@ rv31_Use16Bit13: shl esi,4 add esi,eax mov ax,w[rv31_FlagsStore] + ;clear IF & TF & DF and ax,NOT (EFLAG_IF or EFLAG_TF or EFLAG_DF) + ;retain IF & TF & DF and WORD PTR fs:[esi+IFrame16.i16_flags],EFLAG_IF or EFLAG_TF or EFLAG_DF or fs:[esi+IFrame16.i16_flags],ax ; @@ -2797,8 +2800,10 @@ EmuRawPL0toPL3 proc near push edx ;ESP pushfd ;EFlags pop eax - and ax,NOT (EFLAG_NT or EFLAG_IOPL) ;clear NT & IOPL. - or ax,EFLAG_IOPL ;force IOPL 3. + ;clear NT & IOPL. + and ax,NOT (EFLAG_NT or EFLAG_IOPL) + ;force IOPL 3. + or ax,EFLAG_IOPL push eax popfd push eax @@ -2969,8 +2974,8 @@ rv46_000A_0: push es push eax mov edi,offset RawSelBuffer - Round8UP edi - mov ax,KernalDS ;DpmiEmuDS + Round8UP edi ;allign pointer to 8 bytes + mov ax,KernalDS ;DpmiEmuDS mov es,ax call RawBGetDescriptor ;copy original details. mov BYTE PTR es:[edi+5],DescPresent+DescPL3+DescMemory+DescRWData @@ -3055,7 +3060,7 @@ rv46_DPMI_0101: cmp ax,dx pop eax push eax - jne med2_0101 ; not attempting to release SS selector + jne med2_0101 ; not attempting to release SS selector stc ; flag failure, but no error code update jmp med3_0101 @@ -3075,7 +3080,7 @@ rv46_0101_0: jmp rv46_Done ; rv46_DPMI_0102: - cmp al,02h ;re-size DOS memory? + cmp al,02h ;re-size DOS memory? jnz rv46_NotOurs push ebp push eax @@ -3097,19 +3102,19 @@ rv46_0102_0: jmp rv46_Done ; rv46_DPMI_0200: - cmp al,00h ;get real mode vector? + cmp al,00h ;get real mode vector? jnz rv46_DPMI_0201 call RawGetRVector jmp rv46_Done ; rv46_DPMI_0201: - cmp al,01h ;set real mode vector? + cmp al,01h ;set real mode vector? jnz rv46_DPMI_0202 call RawSetRVector jmp rv46_Done ; rv46_DPMI_0202: - cmp al,02h ;get exception vector? + cmp al,02h ;get exception vector? jnz rv46_DPMI_0203 push eax push ecx @@ -3134,7 +3139,7 @@ rv46_0202_1: jmp rv46_Done ; rv46_DPMI_0203: - cmp al,03h ;set exception vector? + cmp al,03h ;set exception vector? jnz rv46_DPMI_0204 push edx assume ds:nothing @@ -3148,7 +3153,7 @@ rv46_0203_0: jmp rv46_Done ; rv46_DPMI_0204: - cmp al,04h ;get vector? + cmp al,04h ;get vector? jnz rv46_DPMI_0205 push eax push ecx @@ -3173,7 +3178,7 @@ rv46_0204_1: jmp rv46_Done ; rv46_DPMI_0205: - cmp al,05h ;set vector? + cmp al,05h ;set vector? jnz rv46_NotOurs push edx assume ds:nothing @@ -3187,7 +3192,7 @@ rv46_0205_0: jmp rv46_Done ; rv46_DPMI_0300: - cmp al,00h ;Simulate int? + cmp al,00h ;Simulate int? jnz rv46_DPMI_0301 ; ;Extend [E]DI to EDI @@ -3233,7 +3238,8 @@ rv46_0300_0: mov bx,ss:[esp+(4+4+4+2)+IFrame.i_eflags] ;get original flags. and bx,EFLAG_IF or EFLAG_DF or EFLAG_OF ;retain IF. rv46_0300_1: - and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF) ;lose IF. + ;clear IF & DF & OF. + and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF) or es:RealRegsStruc.Real_Flags[edi],bx popf ; @@ -3291,7 +3297,8 @@ rv46_0301_0: mov bx,ss:[esp+(4+4+4+2)+IFrame.i_eflags] ;get original flags. and bx,EFLAG_IF or EFLAG_DF or EFLAG_OF ;retain IF. rv46_0301_1: - and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF) ;lose IF. + ;clear IF & DF & OF. + and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF) or es:RealRegsStruc.Real_Flags[edi],bx popf ; @@ -3348,7 +3355,8 @@ rv46_0302_0: mov bx,ss:[esp+(4+4+4+2)+IFrame.i_eflags] ;get original flags. and bx,EFLAG_IF or EFLAG_DF or EFLAG_OF ;retain IF. rv46_0302_1: - and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF) ;lose IF. + ;clear IF & DF & OF. + and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF) or es:RealRegsStruc.Real_Flags[edi],bx popf ; @@ -4243,8 +4251,10 @@ rv46_Done: rv46_Use32Bit8: mov bx,[esp+(4+4)+IFrame.i_eflags] ;get original flags. rv46_Use16Bit8: - and bx,EFLAG_IF or EFLAG_DF or EFLAG_OF ;retain IF. - and ax,NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF) ;lose IF. + ;retain IF & DF & OF. + and bx,EFLAG_IF or EFLAG_DF or EFLAG_OF + ;clear IF & DF & OF. + and ax,NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF) or ax,bx ;get old IF. assume ds:nothing test BYTE PTR cs:DpmiEmuSystemFlags,1 @@ -5993,8 +6003,10 @@ rv64_Done: rv64_Use32Bit8: mov ebx,[esp+(4+4)+IFrame.i_eflags] ;get original flags. rv64_Use16Bit8: - and bx,EFLAG_IF or EFLAG_DF or EFLAG_OF ;retain IF. - and ax,NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF) ;lose IF. + ;retain IF & DF & OF. + and bx,EFLAG_IF or EFLAG_DF or EFLAG_OF + ;clear IF & DF & OF. + and ax,NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF) or eax,ebx ;get old IF. assume ds:nothing test BYTE PTR cs:DpmiEmuSystemFlags,1