Skip to content

Commit

Permalink
causeway: cleanup code
Browse files Browse the repository at this point in the history
use EFLAG_.. macros where possible
  • Loading branch information
jmalak committed Jan 28, 2025
1 parent 00e6164 commit 61c55f2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
8 changes: 4 additions & 4 deletions bld/causeway/asm/cw32.asm
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ EFLAG_IOPL equ (3 shl 12) ; I/O privilege level
EFLAG_NT equ (1 shl 14) ; nested task

EFLAGS_UNUSED equ 1000000000101010b

EFLAGS_MASK1 equ (0FFFFh and NOT (EFLAGS_UNUSED or EFLAG_NT))
EFLAGS_MASK2 equ (0FFFFh and NOT (EFLAGS_UNUSED or EFLAG_NT or EFLAG_IOPL or EFLAG_IF or EFLAG_TF))
;EFLAGS_ARITHM 0000100011010101b
EFLAGS_ARITHM equ (EFLAG_OF or EFLAG_SF or EFLAG_ZF or EFLAG_AF or EFLAG_PF or EFLAG_CF)

PAGE_PRESENT equ (1 shl 0)
PAGE_WRITE equ (1 shl 1)
Expand Down Expand Up @@ -2127,7 +2126,8 @@ cw5_InProt:
;
pushfd
pop eax
and ax,1011111111111111b ;clear NT.
;clear NT.
and ax,NOT EFLAG_NT
push eax
popfd

Expand Down
9 changes: 6 additions & 3 deletions bld/causeway/asm/int10h.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1034,9 +1034,12 @@ int103_Done:
int103_Use32Bit8:
mov bx,ss:[esp+(4+4)+(4+4)] ;get original flags.
int103_Use16Bit8:
and bx,0000011000000000b ;retain IF.
and ax,1111100111111111b ;lose IF.
or ax,bx ;get old IF.
;retain IF & DF.
and bx,EFLAG_IF or EFLAG_DF
;clear IF & DF.
and ax,NOT (EFLAG_IF or EFLAG_DF)
;get old IF & DF.
or ax,bx
push ds
mov ds,cs:Int10hDSeg
assume ds:_cwMain
Expand Down
9 changes: 6 additions & 3 deletions bld/causeway/asm/int33h.asm
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,12 @@ int333_Done:
int333_Use32Bit8:
mov bx,ss:[esp+(4+4)+(4+4)] ;get original flags.
int333_Use16Bit8:
and bx,0000011000000000b ;retain IF.
and ax,1111100111111111b ;lose IF.
or ax,bx ;get old IF.
;retain IF & DF.
and bx,EFLAG_IF or EFLAG_DF
;clear IF & DF.
and ax,NOT (EFLAG_IF or EFLAG_DF)
;get old IF & DF.
or ax,bx
push ds
mov ds,cs:Int33hDSeg
assume ds:_cwMain
Expand Down
6 changes: 4 additions & 2 deletions bld/causeway/asm/interrup.asm
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,8 @@ IntHandler proc near
; ESP:SS ------------------------------------------/
;
jnz inter14_NoCode
and w[esp+(4+4)+(4)+(4)+IFrame.i_eflags],EFLAGS_MASK1
;clear NT
and w[esp+(4+4)+(4)+(4)+IFrame.i_eflags],NOT EFLAG_NT

; MED 12/02/95
; check if Exception Index is 0dh
Expand Down Expand Up @@ -930,7 +931,8 @@ mednoem:
add esp,4 ;skip error code.
jmp inter14_SortedCode2
inter14_NoCode:
and w[esp+(4+4)+(4)+IFrame.i_eflags],EFLAGS_MASK1
;clear NT.
and w[esp+(4+4)+(4)+IFrame.i_eflags],NOT EFLAG_NT
mov eax,[esp+(4+4)+(4)+IFrame.i_eflags] ;Get flags.
mov ExceptionFlags,eax ;/
mov b ExceptionType,0 ;unset exception
Expand Down
11 changes: 7 additions & 4 deletions bld/causeway/asm/raw_vcpi.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,8 @@ rv29_Back:
cli
cld
pop WORD PTR cs:[rv29_IntAdd]
and WORD PTR cs:[rv29_IntAdd],EFLAGS_MASK2
;clear NT & IOPL & IF & TF
and WORD PTR cs:[rv29_IntAdd],NOT (EFLAG_NT or EFLAG_IOPL or EFLAG_IF or EFLAG_TF)
;
;Switch back to old stack.
;
Expand Down Expand Up @@ -1873,8 +1874,8 @@ 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)
;clear DF & OF & SF & ZF & AF & PF & CF
and bx,NOT (EFLAG_DF or EFLAGS_ARITHM)
or es:RealRegsStruc.Real_Flags[edi],bx
;
cmp w[rv29_ourstack],0
Expand Down Expand Up @@ -2206,7 +2207,9 @@ rv31_NotBusy:
or cs:CallBackStruc.CallBackFlags[bx],128 ;mark it as busy.
mov bx,sp
mov ax,ss:[bx+(2+2+2)+(2+2)]
and ax,EFLAGS_MASK2
;clear NT & IOPL & IF & TF
and ax,NOT (EFLAG_NT or EFLAG_IOPL or EFLAG_IF or EFLAG_TF)
;force bit 1 ????
or ax,0000000000000010b
mov WORD PTR cs:[rv31_FlagsStore],ax
pop dx
Expand Down

0 comments on commit 61c55f2

Please sign in to comment.