cw32.asm
来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 2,222 行 · 第 1/5 页
ASM
2,222 行
div cx
add al,'0'
mov b[ErrorM00n],al
add dl,'0'
mov b[ErrorM00n+1],dl
cmp EnableDebugDump,0 ; if debug dump turned off, no screen i/o
je cw2_NoError
xor edx,edx
mov dx,w[ErrorList]
mov ah,9
int 21h
;
;Get a pointer to the appropriate error message and print it.
;
mov bx,ErrorNumber
add bx,bx
xor edx,edx
mov dx,[ErrorList+bx]
mov ah,9
int 21h
;
;Now exit with the error number as the DOS "errorlevel".
;
cw2_NoError:
;
;Remove extension patches.
;
mov di,offset ExtensionList ;list of interupt patches.
cw2_p1: cmp w[di+2],-1 ;search for the end of the table so we can restore
jz cw2_p0 ;vectors in reverse order.
add di,2
jmp cw2_p1
;
cw2_p0: mov bp,w[di]
cmp WORD PTR ds:[bp+32],-1 ;installed?
jnz cw2_p2
push di
push bp
push cs
push offset cw2_p3
push WORD PTR ds:[bp+20]
push WORD PTR ds:[bp+16]
retf
cw2_p3:
pop bp
pop di
cw2_p2: sub di,2
cmp di,offset ExtensionList-2
jnz cw2_p0
;
;Remove api exception patches.
;
cmp apiExcepPatched,0
jz cw2_pe0
mov ax,cs
push ax
mov ax,offset cw2_pe0
push ax
mov ax,apiCodeSeg
push ax
mov eax,offset UnPatchExc
push ax
retf
cw2_pe0: ;
;
;Remove the API patch.
;
mov es,apiDataSeg
assume es:_apiCode
test BYTE PTR SystemFlags,1
jz cw2_Use32
mov dx,WORD PTR es:[OldIntSys]
mov cx,WORD PTR es:[OldIntSys+2]
jmp cw2_Use0
cw2_Use32: mov edx,DWORD PTR es:[OldIntSys]
mov cx,WORD PTR es:[OldIntSys+4]
cw2_Use0: mov bl,31h
mov ax,205h
int 31h
mov DWORD PTR es:[cwIdentity],0
mov DWORD PTR es:[cwIdentity+4],0
assume es:nothing
;
cw2_noAPI:
cmp ProtectedType,2 ;DPMI?
jz cw2_DPMI
;
;Make RAW stuff addressable.
;
cli ;Don't want interrupts interfering.
mov ax,KernalDS ;Get supervisor data descriptor,
mov ds,ax ;DS,ES,FS,GS,SS must be data with 64k limit
assume ds:_cwRaw
mov ax,KernalZero
mov es,ax
;
;Switch to RAW exit code.
;
push _cwMain
push offset cw2_6
mov ax,KernalCS
push ax
mov ax,offset RawVCPIRealMode
push ax
retf
cw2_6: jmp cw2_RealMode
;
;Remove DPMI stuff.
;
cw2_DPMI:
assume ds:nothing
mov ds,cs:DataSegment
assume ds:_cwMain
if 0
cmp d[OldInt21hExec],0
jz cw2_d0
mov bl,21h
mov dx,w[OldInt21hExec]
mov cx,w[OldInt21hExec+2]
mov ax,201h
int 31h
cw2_d0: movzx edx,dx
endif
jmp cw2_InRealMode
;
;Make sure our data is addressable.
;
cw2_RealMode: mov ax,_cwMain
mov ds,ax
assume ds:_cwMain
;
;Display the "CauseWay error: ??" bit.
;
cw2_InRealMode:
if 0
cmp ErrorNumber,0
jz cw2_NoError
push ax
mov al,3
call bordm
pop ax
mov ax,ErrorNumber ;Get the error number.
xor dx,dx
mov cx,10
div cx
add al,'0'
mov b[ErrorM00n],al
add dl,'0'
mov b[ErrorM00n+1],dl
cmp EnableDebugDump,0 ; if debug dump turned off, no screen i/o
je cw2_NoError
xor edx,edx
mov dx,w[ErrorList]
mov ah,9
int 21h
;
;Get a pointer to the appropriate error message and print it.
;
mov bx,ErrorNumber
add bx,bx
mov dx,[ErrorList+bx]
mov ah,9
int 21h
;
;Now exit with the error number as the DOS "errorlevel".
;
cw2_NoError:
endif
; MED, 12/24/99, coalesce free memory by attempting to allocate largest possible
; with upper memory in the chain
mov ax,5800h
int 21h
push ax
mov ax,5802h
int 21h
push ax
mov bx,1
mov ax,5803h
int 21h
mov bx,81h
mov ax,5801h
int 21h
mov ah,48h
mov bx,-1
int 21h
pop bx
mov ax,5803h
int 21h
pop bx
mov ax,5801h
int 21h
mov ax,ErrorNumber
or ax,ax
jnz cw2_Exit
mov ax,ErrorLevel
cw2_Exit:
mov ah,4ch
int 21h
cwClose endp
;-------------------------------------------------------------------------------
Int21hExecPatch proc near
assume ds:nothing
pushf
cmp ax,4b00h
jnz cw3_Old
inc BYTE PTR cs:Int21hExecCount
popf
pushf
call DWORD PTR cs:[OldInt21hExec]
pushf
push bp
push ax
mov bp,sp
mov ax,[bp+2+2]
and ax,1
; and w[bp+2+2+2+2+2],1
and w[bp+2+2+2+2+2],0fffeh ; MED 01/24/96
or w[bp+2+2+2+2+2],ax
pop ax
pop bp
popf
dec BYTE PTR cs:Int21hExecCount
iret
cw3_Old:
popf
jmp DWORD PTR cs:[OldInt21hExec]
OldInt21hExec dd 0
assume ds:_cwMain
Int21hExecCount db 0
Int21hExecPatch endp
.386p
;-------------------------------------------------------------------------------
Bordm proc near
push ax
push dx
mov ah,al
mov dx,3dah
in al,dx
mov dl,0c0h
mov al,11h
out dx,al
mov al,ah
out dx,al
mov al,20h
out dx,al
pop dx
pop ax
ret
Bordm endp
_cwMain ends
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Default stack used during startup and exit.
;
_cwStack segment para stack 'stack' use16
db 2048 dup (0)
_cwStackEnd label byte
_cwStack ends
include raw_vcpi.asm
include api.asm
include exceptn.asm
include int10h.asm
include int21h.asm
include int33h.asm
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;The initialiseation code seg. Takes care of things like checking for the right
;processor and determining how we're going to get into protected mode.
;
_cwInit segment para public 'init code' use16
assume cs:_cwInit, ds:_cwMain
dpmiSelBuffer db 8 dup (0)
;-------------------------------------------------------------------------------
;
;Initialisation specific data.
;
apiDataSegi dw 0
IProtectedMode db 0
IProtectedType dw 0
DPMISwitch dw ?,?
dpmiSelBase dd 0
dpmiCodeSel dw ?
dpmiDataSel dw ?
;
iCodeSegment dw InitCS
mCodeSegment dw MainCS
iDataSegment dw InitDS
mDataSegment dw MainDS
iStackSegment dw MainSS
iPSPSegment dw MainPSP
iENVSegment dw MainENV
iRealSegment dw KernalZero
;
INewHeader NewHeaderStruc <> ;make space for a header.
;
IExeSignature db ? ;00 Identifier text.
db ? ;01 /
IExeLength dw ? ;02 Length of file MOD 512
dw ? ;04 Length of file in 512 byte blocks.
IExeRelocNum dw ? ;06 Number of relocation items.
IExeHeaderSize dw ? ;08 Length of header in 16 byte paragraphs.
IExeMinAlloc dw ? ;0A Minimum number of para's needed above program.
IExeMaxAlloc dw ? ;0C Maximum number of para's needed above program.
IExeStackSeg dw ? ;0E Segment displacement of stack module.
IExeEntrySP dw ? ;10 value for SP at entry.
IExeCheckSum dw ? ;12 Check sum...
IExeEntryIP dw ? ;14 Contents of IP at entry.
IExeEntryCS dw ? ;16 Segment displacement of CS at entry.
IExeRelocFirst dw ? ;18 First relocation item offset.
IExeOverlayNum db ? ;1A Overlay number.
;
IErrorNumber dw 0
InitErrorList dw IErrorM00,IErrorM01,IErrorM02,IErrorM03,IErrorM04,IErrorM05,IErrorM06,IErrorM07
dw IErrorM08,IErrorM09
IErrorM00 db 'CauseWay error '
IErrorM00n db '00 : $'
IErrorM01 label byte
if ENGLISH
db 'Unable to re-size program memory block.',13,10,'$'
elseif SPANISH
db "Incapaz de redimensionar el bloque de memoria del programa",13,10,"$"
endif
IErrorM02 label byte
if ENGLISH
db '386 or better required.',13,10,'$'
elseif SPANISH
db "Se requiere un 386 o superior.",13,10,"$"
endif
IErrorM03 label byte
if ENGLISH
db 'Non-standard protected mode program already active.',13,10,'$'
elseif SPANISH
db "Programa en modo protegido no estandar activado.",13,10,"$"
endif
IErrorM04 label byte
if ENGLISH
db 'DOS 3.1 or better required.',13,10,'$'
elseif SPANISH
db "DOS 3.1 o superior requerido.",13,10,"$"
endif
IErrorM05 label byte
if ENGLISH
db 'Not enough memory for CauseWay.',13,10,'$'
elseif SPANISH
db "Memoria insuficiente para CauseWay.",13,10,"$"
endif
IErrorM06 label byte
if ENGLISH
db 'VCPI failed to switch into protected mode.',13,10,'$'
elseif SPANISH
db "VCPI fallo al cambiar a modo protegido.",13,10,"$"
endif
IErrorM07 label byte
if ENGLISH
db 'Unable to control A20.',13,10,'$'
elseif SPANISH
db "Capaz de controlar A20.",13,10,"$"
endif
IErrorM08 label byte
if ENGLISH
db 'Selector allocation error.',13,10,'$'
elseif SPANISH
db "Error de asignacion del selector.",13,10,"$"
endif
IErrorM09 label byte
if ENGLISH
db 'DPMI failed to switch to protected mode.',13,10,'$'
elseif SPANISH
db "DPMI fallo al cambiar a modo protegido.",13,10,"$"
endif
;
IFDEF PERMNOVM
NoVMSwitch db 1
ELSE
NoVMSwitch db 0
ENDIF
VMMDrivPath1 db 128 dup (0) ;used by CAUSEWAY=SWAP:?:\??
VMMDrivPath2 db 128 dup (0) ;used by TEMP=
VMMDrivPath3 db 128 dup (0) ;used by TMP=
VMMDrivPath4 db 128 dup (0) ;used by current path.
VMMDrivPath5 db 128 dup (0) ;used by boot drive.
db -1
;
DPMIErrRegs db size RealRegsStruc dup (0)
;
;-------------------------------------------------------------------------------
Startup proc near
;
;Make global data addresable.
;
mov ax,_cwMain
mov ds,ax
; MED, 12/30/99
; works around weird bug in some machines due to Windows/hardware/BIOS??? error
; where a CauseWay application in AUTOEXEC.BAT which uses DOS function 8
; to get a keystroke when no other application in AUTOEXEC.BAT gets a
; keystroke will cause failure in Windows 98 (and 95?) when opening a DOS
; box after Windows startup. Caused by A20 or keyboard port stabilization?
mov cx,127
IFNDEF SUN
kloop:
mov ax,0b00h
int 21h
test al,al
jne done
loop kloop
done:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?