Skip to content

Commit

Permalink
causeway: causeway: cleanup code
Browse files Browse the repository at this point in the history
use new macros where possible to do code more transparent
add new and update comments
  • Loading branch information
jmalak committed Jan 26, 2025
1 parent ff01a04 commit a3504ad
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 248 deletions.
212 changes: 106 additions & 106 deletions bld/causeway/asm/api.asm

Large diffs are not rendered by default.

32 changes: 14 additions & 18 deletions bld/causeway/asm/cw32.asm
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ ClearDescRPL macro r
_and_not_byte r,3 ;clear RPL bits
endm

ClearDescTIRPL macro r
_and_not_byte r,7 ;clear RPL & TI bits
endm

b equ byte ptr
w equ word ptr
d equ dword ptr
Expand Down Expand Up @@ -1962,7 +1958,7 @@ cw5_VCPI:
xor di,di ;Page table offset.
mov es,Page1stReal ;Page table segment
mov si,VCPI_0 ;VCPI GDT entries offset.
and si,not 3
ClearDescRPL si
mov ds,GDTReal ;GDT segment.
mov ax,0de01h ;Let VCPI server prepare.
int 67h
Expand Down Expand Up @@ -1997,7 +1993,7 @@ cw5_VCPI:
GetPageIndex edi ;page number.
shl edi,2 ;*4 bytes per entry.
mov eax,es:[di] ;get physical address.
ClearUseBits eax ;clear status bits.
ClearUseBits eax ;clear use bits.
mov VCPISW.VCPI_CR3,eax ;set VCPI CR3 value as well.
mov es,KernalTSSReal
xor di,di
Expand Down Expand Up @@ -2218,7 +2214,7 @@ cw5_1: jnz InitError
mov eax,1022
mov esi,PageDirLinear
mov edx,LinearEntry+8 ;get physical address again.
SetUseBits edx
SetUseBits edx ;user+write+present
mov es:[esi+eax*4],edx ;put new page into the map.
mov esi,PageAliasLinear
mov es:[esi+eax*4],edx ;put new page into the map.
Expand All @@ -2244,7 +2240,7 @@ cw5_1: jnz InitError
mov esi,PageDETLinear
mov eax,0
mov edx,LinearEntry+8 ;get physical address again.
SetUseBits edx
SetUseBits edx ;user+write+present
mov es:[esi+eax*4],edx ;put new page into the map.
call d[fCR3Flush]
inc LinearEntry
Expand All @@ -2268,7 +2264,7 @@ cw5_1: jnz InitError
mov esi,PageDETLinear
mov eax,1
mov edx,LinearEntry+8 ;get physical address again.
SetUseBits edx
SetUseBits edx ;user+write+present
mov es:[esi+eax*4],edx ;put new page into the map.
call d[fCR3Flush]
inc LinearEntry
Expand Down Expand Up @@ -2301,14 +2297,14 @@ cw5_1: jnz InitError
mov esi,PageDirLinear
mov eax,1023
mov edx,LinearEntry+8 ;get physical address again.
SetUseBits edx
SetUseBits edx ;user+write+present
mov ecx,es:[esi+eax*4] ;get original value.
mov PageAliasLinear+8,ecx
mov es:[esi+eax*4],edx ;put new page into the map.
mov esi,PageAliasLinear
mov eax,1023
mov edx,LinearEntry+8 ;get physical address again.
SetUseBits edx
SetUseBits edx ;user+write+present
mov es:[esi+eax*4],edx ;put new page into the map.
call d[fCR3Flush]
inc LinearEntry
Expand Down Expand Up @@ -2354,7 +2350,7 @@ COMMENT !
;Set new address in page dir.
;
mov edx,LinearEntry+8 ;get physical address again.
SetUseBits edx
SetUseBits edx ;user+write+present
;
mov esi,PageDirLinear
mov eax,0
Expand Down Expand Up @@ -2781,8 +2777,8 @@ drivefree:
jz cw5_v7
mul cx ;Get bytes per cluster.
mul bx ;Get bytes available.
shl edx,16
mov dx,ax
shl edx,16 ;dx:ax -> edx
mov dx,ax ;/
cmp edx,ebp ;Enough free space.
jc cw5_v7
;
Expand Down Expand Up @@ -2889,8 +2885,8 @@ cw5_v2: mov VMMName,al
je medpre2
mov bx,VMMHandle
mov ecx,PreAllocSize
mov dx,cx
shr ecx,16
mov dx,cx ;ecx -> cx:dx
shr ecx,16 ;/
mov ax,4200h ; seek from beginning of file
int 21h
xor cx,cx ; write zero bytes (pre-allocating based on seek)
Expand Down Expand Up @@ -3220,8 +3216,8 @@ cw5_InProtected:
mov ax,0600h
int 31h ;Lock memory.
jc InitError
shl ebx,16
mov bx,cx
shl ebx,16 ;bx:cx -> ebx
mov bx,cx ;/
mov dpmiSelBase,ebx
;
;Allocate code selector.
Expand Down
6 changes: 3 additions & 3 deletions bld/causeway/asm/exceptn.asm
Original file line number Diff line number Diff line change
Expand Up @@ -957,9 +957,9 @@ DebugSegmentDPMI proc near
push dx
mov ax,0006h
int 31h
mov ax,cx
shl eax,16
mov ax,dx
mov ax,cx ;cx:dx -> eax
shl eax,16 ;/
mov ax,dx ;/
pop dx
pop cx
sub eax,DWORD PTR fs:[EPSP_Struc.EPSP_MemBase] ;get offset within application.
Expand Down
18 changes: 9 additions & 9 deletions bld/causeway/asm/int21h.asm
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,9 @@ Int21hAllocMem proc near
jz int2118_AllocMuch
movzx ebx,bx
shl ebx,4 ;convert paragraphs to bytes.
mov dx,bx
shr ebx,16
mov cx,bx
mov dx,bx ;ebx -> cx:dx
shr ebx,16 ;/
mov cx,bx ;/
Sys GetMem ;try to allocate memory.
jc int2118_AllocMuch ;report how much free then.
mov [ebp+Int_AX],bx ;get the selector allocated.
Expand All @@ -756,9 +756,9 @@ int2118_AllocMuch:
mov cx,-1
mov dx,-1
Sys GetMem ;get free memory size.
mov bx,cx
shl ebx,16
mov bx,dx
mov bx,cx ;cx:dx ->ebx
shl ebx,16 ;/
mov bx,dx ;/
cmp ebx,0fffeh*16 ;can't report too much.
jc int2118_AllocOK
mov ebx,0fffeh*16
Expand Down Expand Up @@ -799,9 +799,9 @@ Int21hRelMem endp
Int21hResMem proc near
movzx ebx,w[ebp+Int_BX]
shl ebx,4 ;convert paragraphs to bytes.
mov dx,bx
shr ebx,16
mov cx,bx
mov dx,bx ;ebx -> cx:dx
shr ebx,16 ;/
mov cx,bx ;/
mov bx,[ebp+Int_ES]
Sys ResMem
pushf
Expand Down
14 changes: 7 additions & 7 deletions bld/causeway/asm/ldt.asm
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ ldt3_0: cmp w[esi],0 ;end of the list?
push ecx
mov bx,[esi]
call RawGetSelBase
shl ecx,16
mov cx,dx
shl ecx,16 ;cx:dx -> ecx
mov cx,dx ;/
mov edx,ecx
pop ecx
pop ebx
Expand All @@ -232,9 +232,9 @@ ldt3_New:
push eax
push ebx
push ecx
mov dx,bx
shr ebx,16
mov cx,bx
mov dx,bx ;ebx -> cx:dx
shr ebx,16 ;/
mov cx,bx ;/
mov bx,ax
call RawSetSelBase
pop ecx
Expand Down Expand Up @@ -339,8 +339,8 @@ RawSetSelLimit proc near
movzx esi,bx ;Get the selector.
GetDescIndex esi ;lose RPL & TI.
add esi,MDTLinear ;offset into descriptor table.
shl ecx,16
mov cx,dx
shl ecx,16 ;cx:dx -> ecx
mov cx,dx ;/
xor al,al
cmp ecx,100000h ; see if we need to set g bit
jc ldt5_2
Expand Down
12 changes: 6 additions & 6 deletions bld/causeway/asm/load3p.asm
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ api89_CheckNew:
dec ExecMCount
mov edx,d[apiNewHeader.NewSize]
sub edx,size NewHeaderStruc
mov cx,dx
shr edx,16
mov cx,dx ;edx -> dx:cx
shr edx,16 ;/
xchg cx,dx
mov ax,4201h
int 21h
Expand All @@ -180,8 +180,8 @@ api89_emc0:
xor dx,dx
mov ax,4201h
int 21h
shl edx,16
mov dx,ax
shl edx,16 ;dx:ax -> edx
mov dx,ax ;/
mov d[api89_3PStart],edx
;
;Close the file again.
Expand Down Expand Up @@ -216,8 +216,8 @@ api89_emc0:
;Move past 3P header again.
;
mov edx,d[api89_3PStart]
mov cx,dx
shr edx,16
mov cx,dx ;edx -> dx:cx
shr edx,16 ;/
xchg dx,cx
mov ax,4200h
mov bx,w[api89_Handle]
Expand Down
26 changes: 13 additions & 13 deletions bld/causeway/asm/loadle.asm
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ ENDIF
;
mov ecx,d[LEHeader.LE_ResidentNames]
add ecx,d[load1_LEOffset]
mov dx,cx
shr ecx,16
mov dx,cx ;ecx -> cx:dx
shr ecx,16 ;/
mov bx,w[load1_Handle]
mov ax,4200h
int 21h
Expand Down Expand Up @@ -292,8 +292,8 @@ load1_ge1:
push edx
mov ecx,d[LEHeader.LE_ResidentNames]
add ecx,d[load1_LEOffset]
mov dx,cx
shr ecx,16
mov dx,cx ;ecx -> cx:dx
shr ecx,16 ;/
mov ax,4200h
int 21h
pop edx
Expand Down Expand Up @@ -362,8 +362,8 @@ load1_NoExports:
mov bx,w[load1_Handle]
mov ecx,d[LEHeader.LE_ObjOffset] ;Get object table offset.
add ecx,d[load1_LEOffset]
mov dx,cx
shr ecx,16
mov dx,cx ;ecx -> cx:dx
shr ecx,16 ;/
mov ax,4200h
int 21h
pop ecx
Expand Down Expand Up @@ -461,8 +461,8 @@ load1_objup1:
mov ecx,d[LEHeader.LE_EntryTable]
add ecx,d[load1_LEOffset]
mov bx,w[load1_Handle]
mov dx,cx
shr ecx,16
mov dx,cx ;ecx -> cx:dx
shr ecx,16 ;/
mov ax,4200h
int 21h
;
Expand Down Expand Up @@ -684,9 +684,9 @@ load1_load1:
dec eax
mul d[LEHeader.LE_PageSize] ;* page size.
add eax,d[LEHeader.LE_Data] ;data offset.
mov dx,ax
shr eax,16
mov cx,ax
mov dx,ax ;eax -> cx:dx
shr eax,16 ;/
mov cx,ax ;/
mov ax,4200h
mov bx,w[load1_Handle]
int 21h ;set the file pointer.
Expand Down Expand Up @@ -771,8 +771,8 @@ load1_loadz:
push ecx
mov ecx,d[LEHeader.LE_Fixups]
add ecx,d[load1_LEOffset]
mov dx,cx
shr ecx,16
mov dx,cx ;ecx -> cx:dx
shr ecx,16 ;/
mov bx,w[load1_Handle]
mov ax,4200h
int 21h ;move to fixup data.
Expand Down
Loading

0 comments on commit a3504ad

Please sign in to comment.