From fba42d72866c58169c467652d20475d419b24632 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 18 Jan 2025 01:51:42 +0100 Subject: [PATCH] causeway: cleanup code do code more transparent by using NOT operator align comment to column 41 if possible --- bld/causeway/asm/api.asm | 22 +++---- bld/causeway/asm/cw32.asm | 8 +-- bld/causeway/asm/ldt.asm | 40 ++++++------ bld/causeway/asm/memory.asm | 34 +++++----- bld/causeway/asm/raw_vcpi.asm | 120 +++++++++++++++++----------------- 5 files changed, 112 insertions(+), 112 deletions(-) diff --git a/bld/causeway/asm/api.asm b/bld/causeway/asm/api.asm index 4b0907902b..25e0e9f910 100644 --- a/bld/causeway/asm/api.asm +++ b/bld/causeway/asm/api.asm @@ -1607,32 +1607,32 @@ cwAPI_RelMemSO proc near ;Zero any segment registers using this selector. ; mov bx,w[ebp+Int_SI] - and bx,0ffffh-3 + and bx,NOT 3 jz api33_bad ; MED 11/18/96, screen out null pointer releases xor cx,cx mov ax,w[ebp+Int_DS] - and ax,0ffffh-3 + and ax,NOT 3 cmp ax,bx jnz api33_0 mov w[ebp+Int_DS],cx mov ds,cx api33_0: mov ax,w[ebp+Int_ES] - and ax,0ffffh-3 + and ax,NOT 3 cmp ax,bx jnz api33_1 mov w[ebp+Int_ES],cx mov es,cx api33_1: mov ax,w[ebp+Int_FS] - and ax,0ffffh-3 + and ax,NOT 3 cmp ax,bx jnz api33_2 mov w[ebp+Int_FS],cx mov fs,cx api33_2: mov ax,w[ebp+Int_GS] - and ax,0ffffh-3 + and ax,NOT 3 cmp ax,bx jnz api33_3 mov w[ebp+Int_GS],cx @@ -2715,7 +2715,7 @@ _SetSelector proc near cmp ebx,-1 jz api61_ok add ebx,4095 - and ebx,0FFFFFFFFh-4095 + and ebx,NOT 4095 dec ebx ; api61_ok: @@ -2820,28 +2820,28 @@ _RelSelector proc near push ax push bx push cx - and bx,0ffffh-3 + and bx,NOT 3 xor cx,cx mov ax,ds - and ax,0ffffh-3 + and ax,NOT 3 cmp ax,bx jnz api62_0 mov ds,cx api62_0: mov ax,es - and ax,0ffffh-3 + and ax,NOT 3 cmp ax,bx jnz api62_1 mov es,cx api62_1: mov ax,fs - and ax,0ffffh-3 + and ax,NOT 3 cmp ax,bx jnz api62_2 mov fs,cx api62_2: mov ax,gs - and ax,0ffffh-3 + and ax,NOT 3 cmp ax,bx jnz api62_3 mov gs,cx diff --git a/bld/causeway/asm/cw32.asm b/bld/causeway/asm/cw32.asm index 55c7f903c4..ed638e2a19 100644 --- a/bld/causeway/asm/cw32.asm +++ b/bld/causeway/asm/cw32.asm @@ -1163,7 +1163,7 @@ cw5_A20OFF: shl eax,4 ;linear address. mov ebx,eax add eax,4095 - and eax,0ffffffffh-4095 ;round up to next page. + and eax,NOT 4095 ;round up to next page. sub eax,ebx shr eax,4 mov bx,ax @@ -1193,7 +1193,7 @@ cw5_OldWay: shl eax,4 ;make linear. mov ebx,eax add eax,4095 - and eax,0FFFFFFFFh-4095 ;round up to nearest page. + and eax,NOT 4095 ;round up to nearest page. mov ecx,eax sub ecx,ebx shr ecx,4 @@ -1823,7 +1823,7 @@ cw5_VCPI: shr edi,12 ;page number. shl edi,2 ;*4 bytes per entry. mov eax,es:[di] ;get physical address. - and eax,0FFFFFFFFh-4095 ;clear status bits. + and eax,NOT 4095 ;clear status bits. mov VCPI_CR3,eax ;set VCPI CR3 value as well. mov es,KernalTSSReal xor di,di @@ -1835,7 +1835,7 @@ cw5_VCPI: shr edi,12 ;page number. shl edi,2 ;*4 bytes per entry. mov eax,es:[di] ;get physical address. - and eax,0FFFFFFFFh-4095 ;clear status bits. + and eax,NOT 4095 ;clear status bits. or eax,111b ;user+write+present. mov es,PageDirReal mov di,1023*4 diff --git a/bld/causeway/asm/ldt.asm b/bld/causeway/asm/ldt.asm index 8c26f7e971..ce58fc98d0 100644 --- a/bld/causeway/asm/ldt.asm +++ b/bld/causeway/asm/ldt.asm @@ -116,26 +116,26 @@ RawRelDescriptor proc near push eax push ebx push ecx - and ebx,0ffffh-7 + and ebx,0ffffh AND (NOT 7) ;lose RPL & TI xor ecx,ecx xor eax,eax mov ax,ds - and eax,not 7 + and eax,not 7 ;lose RPL & TI cmp eax,ebx jnz ldt2_0 mov ds,cx ldt2_0: mov ax,es - and eax,not 7 + and eax,not 7 ;lose RPL & TI cmp eax,ebx jnz ldt2_1 mov es,cx ldt2_1: mov ax,fs - and eax,not 7 + and eax,not 7 ;lose RPL & TI cmp eax,ebx jnz ldt2_2 mov fs,cx ldt2_2: mov ax,gs - and eax,not 7 + and eax,not 7 ;lose RPL & TI cmp eax,ebx jnz ldt2_3 mov gs,cx @@ -151,12 +151,12 @@ ldt2_3: mov ax,KernalDS ;make our data addresable. mov ds,ax assume ds:_cwRaw - mov ax,KernalZero ;make LDT addresable. + mov ax,KernalZero ;make LDT addresable. mov es,ax - movzx esi,bx ;Get selector to use. - shr esi,3 ;/8 for descriptor number. + movzx esi,bx ;Get selector to use. + shr esi,3 ;/8 for descriptor number. add esi,MDTLinear+4 - mov BYTE PTR es:[esi],0 ;mark this entry as free. + mov BYTE PTR es:[esi],0 ;mark this entry as free. movzx esi,bx and esi,not 7 add esi,MDTLinear @@ -333,18 +333,18 @@ RawSetSelLimit proc near mov ax,KernalDS ;make our data addresable. mov ds,ax assume ds:_cwRaw - mov ax,KernalZero ;make LDT addresable. + mov ax,KernalZero ;make LDT addresable. mov es,ax - movzx esi,bx ;Get the selector. - and si,0ffffh-7 ;lose RPL & TI. - add esi,MDTLinear ;offset into descriptor table. + movzx esi,bx ;Get the selector. + and si,NOT 7 ;lose RPL & TI. + add esi,MDTLinear ;offset into descriptor table. shl ecx,16 mov cx,dx xor al,al - cmp ecx,100000h ; see if we need to set g bit + cmp ecx,100000h ; see if we need to set g bit jc ldt5_2 - shr ecx,12 ; div by 4096 - or al,80h ; set g bit + shr ecx,12 ; div by 4096 + or al,80h ; set g bit ldt5_2: mov es:[esi],cx ;store low word of limit. shr ecx,16 or cl,al @@ -380,11 +380,11 @@ RawSetSelBase proc near mov ax,KernalDS ;make our data addressable. mov ds,ax assume ds:_cwRaw - mov ax,KernalZero ;make LDT addressable. + mov ax,KernalZero ;make LDT addressable. mov es,ax - movzx esi,bx ;Get the selector. - and si,0ffffh-7 ;lose RPL & TI. - add esi,MDTLinear ;offset into descriptor table. + movzx esi,bx ;Get the selector. + and si,NOT 7 ;lose RPL & TI. + add esi,MDTLinear ;offset into descriptor table. mov es:[esi+4],cl ;base mid. mov es:[esi+7],ch ;base high. mov es:[esi+2],dx ;base low. diff --git a/bld/causeway/asm/memory.asm b/bld/causeway/asm/memory.asm index e22fb25b14..3450ce5a45 100644 --- a/bld/causeway/asm/memory.asm +++ b/bld/causeway/asm/memory.asm @@ -814,11 +814,11 @@ mem5_2: call PhysicalGetPage jnc mem5_3 call UnMapPhysical jc mem5_10 -mem5_3: and ecx,1 ;put user bits in useful place. +mem5_3: and ecx,1 ;put user bits in useful place. shl ecx,10 - and edx,0FFFFFFFFh-4095 ;lose user bits. + and edx,NOT 4095 ;lose user bits. or edx,111b ;present+user+write. - or edx,ecx ;set use flags. + or edx,ecx ;set use flags. mov DWORD PTR es:[edi],edx ;store this tables address. push edi sub edi,PageDirLinear @@ -1126,10 +1126,10 @@ RawUnLockMemory proc near shl esi,16 mov si,di add esi,ebx - and ebx,0FFFFFFFFh-4095 ;round down to nearest page. + and ebx,NOT 4095 ;round down to nearest page. mov d[_LM_BlockBase],ebx add esi,4095 - and esi,0FFFFFFFFh-4095 ;round up to next page. + and esi,NOT 4095 ;round up to next page. dec esi mov d[_LM_BlockEnd],esi ;store address of last page. ; @@ -1737,11 +1737,11 @@ MapPhysical proc near mov ax,KernalZero ;make everything addresable. mov es,ax ; - and ecx,1 ;put user bits in useful place. + and ecx,1 ;put user bits in useful place. shl ecx,10 - and edx,0FFFFFFFFh-4095 ;lose user bits. - mov eax,LinearEntry ;get new entry number. - shr eax,10 ;/1024 for page dir entry. + and edx,NOT 4095 ;lose user bits. + mov eax,LinearEntry ;get new entry number. + shr eax,10 ;/1024 for page dir entry. ; mov esi,PageDirLinear ;get page table address. test DWORD PTR es:[esi+eax*4],1 ;this page present? @@ -1909,7 +1909,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],0FFFFFFFFh-(3 shl 5) ;clear accesed & dirty bits. + and DWORD PTR es:[esi+eax*4],NOT (3 shl 5) ;clear accesed & dirty bits. call EmuCR3Flush ; mem11_NoRead: @@ -2166,10 +2166,10 @@ mem12_error_anyway: mem12_5: ;Now remove it from the page table and exit. ; - and DWORD PTR fs:[edi],0FFFFFFFFh-1 ;mark as not present. + and DWORD PTR fs:[edi],NOT 1;mark as not present. mov edx,fs:[edi] ;get page entry. mov ecx,edx - and edx,0FFFFFFFFh-4095 ;lose flag bits. + and edx,NOT 4095 ;lose flag bits. shr ecx,10 and ecx,1 ;preserve user flags. call EmuCR3Flush @@ -2779,29 +2779,29 @@ RawRelDOSMemory proc near push ebx push ecx mov ebx,edx - and ebx,0ffffh-7 + and ebx,0ffffh AND (NOT 7) ;lose RPL & TI xor ecx,ecx xor eax,eax mov ax,ds - and eax,not 7 + and eax,not 7 ;lose RPL & TI cmp eax,ebx jnz mem21_z0 mov ds,cx mem21_z0: mov ax,es - and eax,not 7 + and eax,not 7 ;lose RPL & TI cmp eax,ebx jnz mem21_z1 mov es,cx mem21_z1: mov ax,fs - and eax,not 7 + and eax,not 7 ;lose RPL & TI cmp eax,ebx jnz mem21_z2 mov fs,cx mem21_z2: mov ax,gs - and eax,not 7 + and eax,not 7 ;lose RPL & TI cmp eax,ebx jnz mem21_z3 mov gs,cx diff --git a/bld/causeway/asm/raw_vcpi.asm b/bld/causeway/asm/raw_vcpi.asm index a725630d25..53f9b90578 100644 --- a/bld/causeway/asm/raw_vcpi.asm +++ b/bld/causeway/asm/raw_vcpi.asm @@ -801,8 +801,8 @@ rv12_d0: push ds push es mov edx,es:[esi] - and edx,0FFFFFFFFh-4095 - and DWORD PTR es:[esi],0FFFFFFFFh-1 ;mark as no longer present. + and edx,NOT 4095 + and DWORD PTR es:[esi],NOT 1;mark as no longer present. call CR3Flush push edi @@ -880,8 +880,8 @@ notzeroth: push ds push es mov edx,es:[edi] - and DWORD PTR es:[edi],0FFFFFFFFh-1 ;mark as no longer present. - and edx,0FFFFFFFFh-4095 + and DWORD PTR es:[edi],NOT 1;mark as no longer present. + and edx,NOT 4095 call CR3Flush @@ -934,8 +934,8 @@ rv12_3: push ds push es mov edx,es:[esi] - and edx,0FFFFFFFFh-4095 - and DWORD PTR es:[esi],0FFFFFFFFh-1 ;mark as no longer present. + and edx,NOT 4095 + and DWORD PTR es:[esi],NOT 1;mark as no longer present. call CR3Flush @@ -1107,20 +1107,20 @@ RawReal2Prot proc near mov eax,cr0 mov CR0Sav,eax mov eax,VCPI_CR3 ;PageDirLinear - mov cr3,eax ;set page dir address. + mov cr3,eax ;set page dir address. ; MED 10/15/96 -; mov eax,cr0 ;Get machine status & -; or eax,080000001h ;set PM+PG bits. - mov eax,CR0ProtSav ; restore protected mode cr0 status +; mov eax,cr0 ;Get machine status & +; or eax,080000001h ;set PM+PG bits. + mov eax,CR0ProtSav ; restore protected mode cr0 status - mov cr0,eax ;/ - db 0eah ;Absolute 16-bit jump, to clear + mov cr0,eax ;/ + db 0eah ;Absolute 16-bit jump, to clear dw rv16_0,KernalCS0 ;instruction pre-fetch & load CS. rv16_0: mov ax,KernalLDT ;Point to empty LDT descriptor. - lldt ax ;and set LDT. + lldt ax ;and set LDT. mov cx,KernalTS ;Get value for task register. - ltr cx ;and set it. + ltr cx ;and set it. ; ;Make our stuff addresable. ; @@ -1130,9 +1130,9 @@ rv16_0: mov ax,KernalLDT ;Point to empty LDT descriptor. mov esp,tPL0StackSize-4 mov ax,KernalDS ;Get data descriptor. - mov ds,ax ;/ - mov es,ax ;/ - mov gs,ax ;/ + mov ds,ax ;/ + mov es,ax ;/ + mov gs,ax ;/ mov fs,ax ; cld @@ -4743,7 +4743,7 @@ rv54_nomaxlimit: mov RealRegsStruc.Real_SS[edi],0 mov RealRegsStruc.Real_SP[edi],0 pop ax - call EmuRawSimulateFarCall ;lock block & get address. + call EmuRawSimulateFarCall ;lock block & get address. pop cx pop bp pop esi @@ -4751,24 +4751,24 @@ rv54_nomaxlimit: mov ebx,RealRegsStruc.Real_EBX[edi] mov eax,RealRegsStruc.Real_EAX[edi] cmp ax,1 - jnz rv54_9 ;should never happen. + jnz rv54_9 ;should never happen. ; ;BP - Block size in K. ;DX:BX - Block linear address. ; - movzx edi,dx ;get base into 1 reg. - shl edi,16 ;/ - mov di,bx ;/ - mov ebx,edi ;copy into high address. - movzx ebp,bp ;fetch size. - shl ebp,10 ;*1024 (1k) - add ebx,ebp ;get real top. + movzx edi,dx ;get base into 1 reg. + shl edi,16 ;/ + mov di,bx ;/ + mov ebx,edi ;copy into high address. + movzx ebp,bp ;fetch size. + shl ebp,10 ;*1024 (1k) + add ebx,ebp ;get real top. add edi,4095 ;round up to next page. - and edi,0FFFFFFFFh-4095 ;/ - and ebx,0FFFFFFFFh-4095 ;round down to nearest page. + and edi,NOT 4095 ;/ + and ebx,NOT 4095 ;round down to nearest page. mov 2[esi],edi mov 6[esi],ebx ;store base and end. - jmp rv54_3 ;start again. + jmp rv54_3 ;start again. ; rv54_GotOne: ;Update table entry indicated and return physical address. @@ -5166,10 +5166,10 @@ use88hResult2: ; movzx eax,ax GIComputeBytes2: - shl eax,10 ; * 1024 + shl eax,10 ; * 1024 add eax,100000h ;add in 1 meg base address. dec eax - and eax,0FFFFFFFFh-4095 ;round down to nearest page. + and eax,NOT 4095 ;round down to nearest page. mov ebx,eax pop esi pop edi @@ -5178,24 +5178,24 @@ GIComputeBytes2: ;EBX - limit. ; cmp esi,ebx - jnc rv56_9 ;No more available. + jnc rv56_9 ;No more available. mov ecx,ebx - sub ecx,esi ;block size. + sub ecx,esi ;block size. cmp ecx,4096 ;check enough for 1 page. jc rv56_9 ; pushad cmp Int15Size,0 ;set size yet? jnz rv56_GotSize - mov eax,ecx ;get proposed maximum size. - mov ecx,8 ;number of chunks. + mov eax,ecx ;get proposed maximum size. + mov ecx,8 ;number of chunks. xor edx,edx - div ecx ;get chunk size. + div ecx ;get chunk size. inc eax or Int15Size,-1 ;set chunk size to use. and eax,not 4095 jz rv56_GotSize - mov Int15Size,eax ;set chunk size to use. + mov Int15Size,eax ;set chunk size to use. rv56_GotSize: popad cmp ecx,Int15Size @@ -5418,13 +5418,13 @@ rv57_GotBottom: ; ; push esi -; movzx eax,w[Int15Value] ;get pretend value. - mov eax,[Int15Value] ;get pretend value. +; movzx eax,w[Int15Value] ;get pretend value. + mov eax,[Int15Value] ;get pretend value. - shl eax,10 ; * 1024 + shl eax,10 ; * 1024 add eax,100000h ;add in 1 meg base address. dec eax - and eax,0FFFFFFFFh-4095 ;round down to nearest page. + and eax,NOT 4095 ;round down to nearest page. mov ebx,eax ; pop esi @@ -5433,45 +5433,45 @@ rv57_GotBottom: ;EBX - limit. ; cmp esi,ebx - jnc rv57_1 ;No more available. + jnc rv57_1 ;No more available. mov ecx,ebx - sub ecx,esi ;block size. + sub ecx,esi ;block size. cmp ecx,4096 ;check enough for 1 page. jc rv57_1 ; pushad cmp Int15Size,0 ;set size yet? jnz rv57_GotSize - mov eax,ecx ;get proposed maximum size. - mov ecx,8 ;number of chunks. + mov eax,ecx ;get proposed maximum size. + mov ecx,8 ;number of chunks. xor edx,edx - div ecx ;get chunk size. + div ecx ;get chunk size. mov Int15Size,-1 ;default to maximum. cmp eax,4096 ;too small? jc rv57_GotSize - mov Int15Size,eax ;set chunk size to use. + mov Int15Size,eax ;set chunk size to use. rv57_GotSize: popad cmp ecx,Int15Size jc rv57_SizeOK mov ecx,Int15Size rv57_SizeOK: - sub ebx,ecx ;new int 15 value. + sub ebx,ecx ;new int 15 value. ; ;EBX - base. ;ECX - size. ; - shr ecx,12 ;get number of pages. + shr ecx,12 ;get number of pages. add [Int15Total],ecx ; - dec ebx ;move back to previous byte. + dec ebx ;move back to previous byte. sub ebx,100000h ;remove starting point. - shr ebx,10 ;convert to K. + shr ebx,10 ;convert to K. -; mov w[Int15Value],bx ;set new base value. - mov [Int15Value],ebx ;set new base value. +; mov w[Int15Value],bx ;set new base value. + mov [Int15Value],ebx ;set new base value. - inc [Int15Level2] ;move to next level. + inc [Int15Level2] ;move to next level. jmp rv57_0 ; rv57_1: ;Now include any remains of existing blocks. @@ -5638,14 +5638,14 @@ rv58_2: add esi,4 ;next entry. mov eax,es:RealRegsStruc.Real_EAX[edi] ;get segment address. mov [esi],ax ;store it in the table. movzx eax,ax - shl eax,4 ;linear address. + shl eax,4 ;linear address. mov ebx,eax add eax,4095 - and eax,0ffffffffh-4095 ;round up to next page. + and eax,NOT 4095 ;round up to next page. sub eax,ebx shr eax,4 mov 2[esi],ax ;store new size. - jmp rv58_3 ;start again. + jmp rv58_3 ;start again. ; rv58_GotOne: ;Update table entry indicated and return physical address. @@ -5653,13 +5653,13 @@ rv58_GotOne: movzx eax,w[esi] ;Get block base segment. add ax,2[esi] ;Add old length. add w[esi+2],4096/16 ;update length. - shl eax,4 ;linear address. - shr eax,12 ;get page number. + shl eax,4 ;linear address. + shr eax,12 ;get page number. mov bx,KernalZero mov es,bx mov esi,1024*4096*1023 ;base of page alias's. mov eax,es:[esi+eax*4] ;get physical address. - and eax,0ffffffffh-4095 ;lose user bits. + and eax,NOT 4095 ;lose user bits. mov edx,eax ; xor ecx,ecx