exceptn.asm
来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 2,472 行 · 第 1/5 页
ASM
2,472 行
pop edx
pop ecx
pop ebx
pop eax
jmp debuggout
debuggtext1 DB 'Entering DebugDisplay...',0
debuggtext2 DB 13,10
debuggout:
push ecx
mov ecx,100000h
debuggloop:
; dec ecx
; jne debugaloop
pop ecx
ENDIF
push ds
mov ds,cs:ExcepDSeg
assume ds:_cwMain
cmp UserTermFlag,0 ; see if user termination routine
je dd2 ; no
INFOLISTSIZE EQU 104
xor ecx,ecx
mov esi,OFFSET cs:DebugBuffer
mov edi,DWORD PTR UserTermDump
cmp UserTermFlag,1 ; see if 16-bit termination routine
mov UserTermFlag,0 ; reset flag, KEEP CPU FLAG STATUS
jne ut32 ; not
mov ax,WORD PTR UserTermDump+2
mov cx,ax
lsl ecx,ecx
jnz utsi ; invalid selector
mov es,ax
mov cx,INFOLISTSIZE
uttrans16:
mov al,cs:[si]
mov es:[di],al
inc si
inc di
dec cx
jne uttrans16
utsi:
mov si,sp
call DWORD PTR ds:[UserTermRoutine]
mov ds,cs:ExcepDSeg ; restore ds if used
jmp dd2
ut32:
mov ax,WORD PTR UserTermDump+4
mov cx,ax
lsl ecx,ecx
jnz utesi ; invalid selector
mov es,ax
mov cx,INFOLISTSIZE
uttrans32:
mov al,cs:[esi]
mov es:[edi],al
inc esi
inc edi
dec cx
jne uttrans32
utesi:
mov esi,esp
call FWORD PTR ds:[UserTermRoutine]
mov ds,cs:ExcepDSeg ; restore ds if used
dd2:
cmp DebugDump,0 ;register dump needed?
jz exc22_9
mov DebugDump,0
cmp EnableDebugDump,0 ; see if debug dumping enabled
je exc22_9
mov ds,cs:ExcepDDSeg
assume ds:_Excep
;
mov ah,0fh
int 10h
cmp al,3
jz exc22_ModeOk
cmp al,2
jz exc22_ModeOk
cmp al,7
jz exc22_ModeOk
mov ax,3
int 10h
exc22_ModeOk: ;
mov d[exc22_Handle],0
xor cx,cx
mov ah,3ch
; MED 06/18/96
mov ds,cs:ExcepDSeg
assume ds:_cwMain
mov edx,OFFSET NewCWErrName ; try new error file name
cmp ds:[edx],al
je oldcwerr ; no new error file name
int 21h
mov ds,cs:ExcepDDSeg
assume ds:_Excep
jnc debhand ; successfully created new error file
oldcwerr:
mov ds,cs:ExcepDDSeg
assume ds:_Excep
mov edx,offset DebugName
xor cx,cx
mov ah,3ch
int 21h
jc exc22_NoFile
debhand:
mov d[exc22_Handle],eax
exc22_NoFile: ;Display debug info.
;
push ds
mov ds,ExcepDseg
assume ds:_cwMain
mov esi,offset Copyright
xor ecx,ecx
exc22_LookCEnd: cmp b[esi],0
jz exc22_AtCEnd
cmp b[si],"$"
jz exc22_AtCEnd
inc ecx
inc esi
jmp exc22_LookCEnd
exc22_AtCEnd: mov edx,offset Copyright
mov ebx,d[exc22_Handle]
mov ah,40h
int 21h
assume ds:_Excep
pop ds
;
mov ax,DebugExceptionIndex
mov cx,2
mov edi,offset DebugINum
call Bin2Hex
mov ax,w[DebugExceptionCode] ;high word undefined upto 486.
mov cx,4
mov edi,offset DebugENum
call Bin2Hex
;
mov ax,DebugTR
mov cx,4
mov edi,offset DebugTRt
call Bin2Hex
mov eax,DebugCR0
mov cx,8
mov edi,offset DebugCR0t
call Bin2Hex
mov eax,DebugCR2
mov cx,8
mov edi,offset DebugCR2t
call Bin2Hex
mov eax,DebugCR3
mov cx,8
mov edi,offset DebugCR3t
call Bin2Hex
;
mov eax,DebugEAX
mov cx,8
mov edi,offset DebugEAXt
call Bin2Hex
mov eax,DebugEBX
mov cx,8
mov edi,offset DebugEBXt
call Bin2Hex
mov eax,DebugECX
mov cx,8
mov edi,offset DebugECXt
call Bin2Hex
mov eax,DebugEDX
mov cx,8
mov edi,offset DebugEDXt
call Bin2Hex
mov eax,DebugESI
mov cx,8
mov edi,offset DebugESIt
call Bin2Hex
mov eax,DebugEDI
mov cx,8
mov edi,offset DebugEDIt
call Bin2Hex
mov eax,DebugEBP
mov cx,8
mov edi,offset DebugEBPt
call Bin2Hex
mov eax,DebugESP
mov cx,8
mov edi,offset DebugESPt
call Bin2Hex
mov eax,DebugEIP
mov cx,8
mov edi,offset DebugEIPt
call Bin2Hex
mov eax,DebugEFL
mov cx,8
mov edi,offset DebugEFLt
call Bin2Hex
;
mov ax,DebugCS
mov cx,4
mov edi,offset DebugCSt
call Bin2Hex
mov eax,DebugCSApp
mov cx,8
mov edi,offset DebugCSAppt
cmp eax,-1
jnz exc22_0
mov d[edi],'xxxx'
mov d[edi+4],'xxxx'
add edi,8
jmp exc22_1
exc22_0: call Bin2Hex
exc22_1: mov ax,DebugDS
mov cx,4
mov edi,offset DebugDSt
call Bin2Hex
mov eax,DebugDSApp
mov cx,8
mov edi,offset DebugDSAppt
cmp eax,-1
jnz exc22_2
mov d[edi],'xxxx'
mov d[edi+4],'xxxx'
add edi,8
jmp exc22_3
exc22_2: call Bin2Hex
exc22_3: mov ax,DebugES
mov cx,4
mov edi,offset DebugESt
call Bin2Hex
mov eax,DebugESApp
mov cx,8
mov edi,offset DebugESAppt
cmp eax,-1
jnz exc22_4
mov d[edi],'xxxx'
mov d[edi+4],'xxxx'
add edi,8
jmp exc22_5
exc22_4: call Bin2Hex
exc22_5: mov ax,DebugFS
mov cx,4
mov edi,offset DebugFSt
call Bin2Hex
mov eax,DebugFSApp
mov cx,8
mov edi,offset DebugFSAppt
cmp eax,-1
jnz exc22_6
mov d[edi],'xxxx'
mov d[edi+4],'xxxx'
add edi,8
jmp exc22_7
exc22_6: call Bin2Hex
exc22_7: mov ax,DebugGS
mov cx,4
mov edi,offset DebugGSt
call Bin2Hex
mov eax,DebugGSApp
mov cx,8
mov edi,offset DebugGSAppt
cmp eax,-1
jnz exc22_10
mov d[edi],'xxxx'
mov d[edi+4],'xxxx'
add edi,8
jmp exc22_11
exc22_10: call Bin2Hex
exc22_11: mov ax,DebugSS
mov cx,4
mov edi,offset DebugSSt
call Bin2Hex
mov eax,DebugSSApp
mov cx,8
mov edi,offset DebugSSAppt
cmp eax,-1
jnz exc22_12
mov d[edi],'xxxx'
mov d[edi+4],'xxxx'
add edi,8
jmp exc22_13
exc22_12: call Bin2Hex
exc22_13: ;
mov edi,offset DebugSysFlags
push ds
mov ds,ExcepDSeg
assume ds:_cwMain
movzx eax,w[SystemFlags]
assume ds:_Excep
pop ds
mov cx,8
call Bin2Hex
;
;Now print the results.
;
push ds
mov ds,ExcepDseg
assume ds:_cwMain
mov esi,offset Copyright
exc22_cp0: cmp b[esi],0
jz exc22_cp1
mov dl,[esi]
mov ah,2
int 21h
inc esi
jmp exc22_cp0
exc22_cp1: assume ds:_Excep
pop ds
mov edx,offset DebugHeader
mov ah,9
int 21h
mov edx,offset DebugHeader
mov ecx,offset DebugHeaderEnd-(DebugHeader+1+768)
mov ebx,d[exc22_Handle]
mov ah,40h
int 21h
;
;Print message about writing cw.err
;
mov edx,offset WritingCWERR
mov ah,9
int 21h
CSEIPDEBUGDUMPCOUNT EQU 256 ; should be multiple of 16
SSESPDEBUGDUMPCOUNT EQU 256 ; should be multiple of 16
SSEBPDEBUGDUMPCOUNT EQU 256 ; should be multiple of 16
push fs
mov fs,ds:ExcepDSeg
assume fs:_cwMain
mov fs,fs:PSPSegment
assume fs:nothing
mov edi,offset DebugHeader
mov edx,OFFSET LoadAddrDebugText
call DebugTextCopy
xor edx,edx
mov eax,fs:[EPSP_Struc.EPSP_MemBase]
mov cx,8
call Bin2Hex
mov DWORD PTR ds:[edi],0a0d0a0dh
add edi,4
mov edx,offset DebugHeader
sub edi,edx
mov ecx,edi
mov ah,40h
mov ebx,d[exc22_Handle]
int 21h
;
;Do a CS:EIP dump.
;
mov ecx,CSEIPDEBUGDUMPCOUNT
mov fs,DebugCS
mov esi,DebugEIP
test BYTE PTR ExcepSystemFlags,1
jz exc22_cseip32
movzx esi,si
exc22_cseip32:
xor eax,eax
mov ax,fs
lsl eax,eax
cmp eax,-1
jz exc22_flat0
inc eax
exc22_flat0:
mov ebx,esi
add ebx,ecx
cmp ebx,eax
jc exc22_cseip2
sub ebx,eax
sub ecx,ebx
jz exc22_cseip3
js exc22_cseip3
exc22_cseip2:
;
mov edi,offset DebugHeader
mov edx,OFFSET CSEIPDebugText
call DebugTextCopy
xor edx,edx
exc22_cseip0:
push ecx
mov ecx,2
mov al,fs:[esi]
call Bin2Hex
pop ecx
mov b[edi]," "
inc edi
inc esi
inc edx
and dl,0fh
jnz exc22_cseip1
mov WORD PTR ds:[edi],0a0dh
add edi,2
mov eax,20202020h
mov DWORD PTR ds:[edi],eax
mov DWORD PTR ds:[edi+4],eax
add edi,8
mov BYTE PTR ds:[edi],al
inc edi
;
exc22_cseip1:
dec ecx
jnz exc22_cseip0
mov DWORD PTR ds:[edi],0a0d0a0dh
add edi,4
; mov b[edi],"$"
;
mov edx,offset DebugHeader
sub edi,edx
mov ecx,edi
mov ah,40h
mov ebx,d[exc22_Handle]
int 21h
exc22_cseip3:
; Do user-defined dump, if appropriate
mov ds,cs:ExcepDSeg
assume ds:_cwMain ; allow access to user input variables
movzx ecx,WORD PTR DebugUserCount
test ecx,ecx ; no user dump defined
je userdone
mov ax,DebugUserSel
verr ax
jnz userdone
mov fs,ax
mov esi,DebugUserOff
mov al,DebugAsciiFlag
mov ds,cs:ExcepDDSeg ; restore ds for normal variable access
assume ds:_Excep
mov DumpAsciiFlag,al
test BYTE PTR ExcepSystemFlags,1
jz user32
movzx esi,si
user32:
xor eax,eax
mov ax,fs
lsl eax,eax
cmp eax,-1
jz userflat0
inc eax
userflat0:
mov ebx,esi
add ebx,ecx
cmp ebx,eax
jc user2
sub ebx,eax
sub ecx,ebx
jz userdone
js userdone
user2:
mov edi,offset DebugHeader
mov edx,OFFSET UserDebugText
call DebugTextCopy
xor edx,edx
user0:
push ecx
mov ecx,2
mov al,fs:[esi]
cmp DumpAsciiFlag,0 ; show as ASCII if so flagged
je userbin ; binary
cmp al,' ' ; ensure that space or greater
jae userascii
mov al,'.' ; show a period for control characters
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?