Skip to content

Commit

Permalink
causeway: fix a few issue with CF for int 21h
Browse files Browse the repository at this point in the history
update comments
  • Loading branch information
jmalak committed Jan 27, 2025
1 parent 76ead33 commit 9987ab3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 34 deletions.
2 changes: 1 addition & 1 deletion bld/causeway/asm/api.asm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ cwAPI_C2C macro
pushfd
pushfd
pop eax
and al,1
cwAPI_AL2C
popfd
pop eax
Expand All @@ -46,6 +45,7 @@ cwAPI_AL2C macro
local __0, __1
pushfd
assume ds:nothing
and al,EFLAG_CF
test BYTE PTR cs:apiSystemFlags,1
jz __0
or b[ebp+Int_Flags16],al
Expand Down
37 changes: 13 additions & 24 deletions bld/causeway/asm/int21h.asm
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ int2110_ExitCheck:
mov [ebp+Int_BX],ax
DOS4GExtend w[ebp+Int_EBX+2]
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
or al,al
jnz int2110_9
Expand Down Expand Up @@ -434,7 +433,6 @@ Int21hCreateDir proc near
mov bl,21h
Sys IntXX
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
mov eax,es:RealRegsStruc.Real_EAX[edi] ;Get return code.
mov [ebp+Int_AX],ax
Expand Down Expand Up @@ -475,7 +473,6 @@ Int21hCreateFile proc near
mov bl,21h
Sys IntXX
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
mov eax,es:RealRegsStruc.Real_EAX[edi] ;Get return code.
mov [ebp+Int_AX],ax
Expand Down Expand Up @@ -517,7 +514,6 @@ Int21hOpenFile proc near
mov bl,21h
Sys IntXX
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
mov eax,es:RealRegsStruc.Real_EAX[edi] ;Get return code.
mov [ebp+Int_AX],ax
Expand Down Expand Up @@ -561,7 +557,6 @@ int2114_1:
Sys IntXX
pop ebx
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
or al,al ;Carry set?
jz int2114_2
Expand Down Expand Up @@ -648,7 +643,6 @@ int2115_1:
Sys IntXX ;Do the write.
pop ebx
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
or al,al ;Carry set?
jz int2115_2
Expand Down Expand Up @@ -714,7 +708,6 @@ Int21hGetCurDir proc near
mov [ebp+Int_AX],ax
DOS4GExtend w[ebp+Int_EAX+2]
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
or al,al
jnz int2117_9
Expand Down Expand Up @@ -769,7 +762,9 @@ int2118_AllocOK:
DOS4GExtend w[ebp+Int_EBX+2]
mov w[ebp+Int_AX],1
DOS4GExtend w[ebp+Int_EAX+2]
call Int21hAL2Carry ;Set carry.
;Set carry.
mov al,EFLAG_CF
call Int21hAL2Carry
ret
Int21hAllocMem endp

Expand Down Expand Up @@ -807,7 +802,6 @@ Int21hResMem proc near
Sys ResMem
pushf
pop ax
and al,1
call Int21hAL2Carry ;Set carry.
ret
Int21hResMem endp
Expand All @@ -820,8 +814,9 @@ Int21hResMem endp
Int21hExecFile proc near
cmp b[ebp+Int_AL],0 ;We only support sub-function 0.
jz int2121_OK
int2121_Done:
call Int21hAL2Carry ;Set carry.
;Set carry.
mov al,EFLAG_CF
call Int21hAL2Carry
ret
;
int2121_OK:
Expand Down Expand Up @@ -1002,8 +997,8 @@ int2121_3:
Sys IntXX ;allocate this memory.
mov eax,es:RealRegsStruc.Real_EAX[edi] ;get segment address.
test es:RealRegsStruc.Real_Flags[edi],EFLAG_CF
mov di,ax
mov al,1
mov di,ax
mov al,EFLAG_CF
jnz int2121_Ef13
movzx edi,di
push edi
Expand Down Expand Up @@ -1110,7 +1105,6 @@ int2121_Ef15:
;
pop ax
int2121_Ef13:
and al,EFLAG_CF
call Int21hAL2Carry
ret
Int21hExecFile endp
Expand Down Expand Up @@ -1152,7 +1146,6 @@ Int21hFindFirstFile proc near
mov [ebp+Int_AX],ax
DOS4GExtend w[ebp+Int_EAX+2]
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.

; or al,al
Expand Down Expand Up @@ -1188,7 +1181,6 @@ Int21hFindNextFile proc near
mov [ebp+Int_AX],ax
DOS4GExtend w[ebp+Int_EAX+2]
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
; or al,al
; jnz @@9
Expand Down Expand Up @@ -1272,7 +1264,6 @@ Int21hRenameFile proc near
DOS4GExtend w[ebp+Int_EAX+2]

mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.

ret
Expand Down Expand Up @@ -1308,7 +1299,6 @@ Int21hCreateTemp proc near
mov [ebp+Int_AX],ax
DOS4GExtend w[ebp+Int_EAX+2]
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
or al,al
jnz int2127_9
Expand Down Expand Up @@ -1350,7 +1340,6 @@ Int21hMSNet proc near
mov [ebp+Int_AX],ax
DOS4GExtend w[ebp+Int_EAX+2]
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
or al,al
jnz int2128_9
Expand Down Expand Up @@ -1383,8 +1372,9 @@ Int21hSetHandles proc near
Sys IntXX
test es:RealRegsStruc.Real_Flags[edi],EFLAG_CF
jz int2129_0
mov al,1
call Int21hAL2Carry ;Set carry.
;Set carry.
mov al,EFLAG_CF
call Int21hAL2Carry
mov eax,es:RealRegsStruc.Real_EAX[edi]
mov [ebp+Int_AX],ax
DOS4GExtend w[ebp+Int_EAX+2]
Expand Down Expand Up @@ -1599,13 +1589,12 @@ int2129_shb2:
stc
;
int2129_sh0:
pushf
;Finaly we pass our results back to the caller.
;
mov [ebp+Int_AX],ax
DOS4GExtend w[ebp+Int_EAX+2]
pushf
pop ax
and al,1
call Int21hAL2Carry ;Set carry.
ret
endif
Expand Down Expand Up @@ -1648,7 +1637,6 @@ Int21hExtendOpen proc near
mov [ebp+Int_CX],ax
DOS4GExtend w[ebp+Int_ECX+2]
mov ax,es:RealRegsStruc.Real_Flags[edi]
and al,EFLAG_CF
call Int21hAL2Carry ;Set carry.
ret
Int21hExtendOpen endp
Expand Down Expand Up @@ -1888,6 +1876,7 @@ Int21hStringLen endp

;------------------------------------------------------------------------------
Int21hAL2Carry proc near
and al,EFLAG_CF
test BYTE PTR cs:Int21hSystemFlags,1
jz int2136_32Bit
or b[ebp+Int_Flags16],al
Expand Down
25 changes: 16 additions & 9 deletions bld/causeway/asm/raw_vcpi.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,8 @@ rv18_Resume486:
;
pushfd
pop eax
and ax,NOT EFLAG_NT ;clear NT.
;clear NT.
and ax,NOT EFLAG_NT
push eax
popfd
cld
Expand Down Expand Up @@ -1357,8 +1358,10 @@ RawPL0toPL3 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
Expand Down Expand Up @@ -3236,7 +3239,8 @@ rv46_0300_0a:
jmp rv46_0300_1
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.
;retain IF & DF & OF.
and bx,EFLAG_IF or EFLAG_DF or EFLAG_OF
rv46_0300_1:
;clear IF & DF & OF.
and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF)
Expand Down Expand Up @@ -3295,7 +3299,8 @@ rv46_0301_0a:
jmp rv46_0301_1
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.
;retain IF & DF & OF.
and bx,EFLAG_IF or EFLAG_DF or EFLAG_OF
rv46_0301_1:
;clear IF & DF & OF.
and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF)
Expand Down Expand Up @@ -3353,7 +3358,8 @@ rv46_0302_0a:
jmp rv46_0302_1
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.
;retain IF & DF & OF.
and bx,EFLAG_IF or EFLAG_DF or EFLAG_OF
rv46_0302_1:
;clear IF & DF & OF.
and es:RealRegsStruc.Real_Flags[edi],NOT (EFLAG_IF or EFLAG_DF or EFLAG_OF)
Expand Down Expand Up @@ -4255,7 +4261,8 @@ rv46_Use16Bit8:
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.
;get old flags.
or ax,bx
assume ds:nothing
test BYTE PTR cs:DpmiEmuSystemFlags,1
assume ds:_cwDPMIEMU
Expand Down Expand Up @@ -5141,7 +5148,7 @@ GIGetMem2:
mov RealRegsStruc.Real_SP[edi],0
call EmuRawSimulateInt

test BYTE PTR RealRegsStruc.Real_Flags[edi],EFLAG_CF ; see if carry returned
test BYTE PTR RealRegsStruc.Real_Flags[edi],EFLAG_CF
je GIProcess2 ; nope
cmp Big1Flag,0
je GIProcess2 ; not using alternate extended memory, process anyway
Expand Down Expand Up @@ -5357,7 +5364,7 @@ GIGetMem1:
mov RealRegsStruc.Real_SP[edi],0
call EmuRawSimulateInt

test BYTE PTR RealRegsStruc.Real_Flags[edi],EFLAG_CF ; see if carry returned
test BYTE PTR RealRegsStruc.Real_Flags[edi],EFLAG_CF
je GIProcess1 ; nope
cmp Big1Flag,0
je GIProcess1 ; not using alternate extended memory, process anyway
Expand Down

0 comments on commit 9987ab3

Please sign in to comment.