DOS中断跟踪,在纯Dos下使用,分析Dos工作原理的最佳工具,原理详看原代码
2005-10-28 21:10
1601 查看
//--DOS中断跟踪,在纯Dos下使用,分析Dos工作原理的最佳工具,原理详看原代码
code segment
assume cs:code
trace: push ax
call far ptr saveintcode
saveintcode: pop ax
shr ax,1
shr ax,1
shr ax,1
shr ax,1
mov cs:intcode,al
pop ax
pop ax
cmp cs:byte ptr exec,0ffh
jz calloldint
cmp cs:byte ptr trapfg,0
jz calloldint
inc cs:word ptr intnumber
mov cs:byte ptr intflag,0
cmp cs:byte ptr input,0
jz calloldint
call procession
cmp cs:byte ptr key,00h
jz calloldint
push ax
xor ax,ax
call int16
pop ax
calloldint: push ax
push bx
push ds
mov bl,cs:intcode
xor bh,bh
shl bx,1
shl bx,1
mov ax,seg data1
mov ds,ax
mov ax,ds:[bx]
mov cs:word ptr oldint,ax
mov ax,ds:[bx+2]
mov cs:word ptr oldint+2,ax
mov bx,sp
mov ax,ss:[bx+0ah]
xchg ax,ss:[bx+4h]
pop ds
pop bx
cli
jmp oldintcall
oldintcall: db 09ah
oldint dd ?
push ax
push bx
pushf
cli
pop ax
mov bx,sp
mov ss:[bx+8h],ax
pop bx
pop ax
cmp cs:byte ptr exec,0ffh
jz retrun
cmp cs:byte ptr trapfg,0
jz retrun
mov cs:byte ptr intflag,0ffh
cmp cs:byte ptr output,00h
jz retrun
call procession
cmp cs:byte ptr key,00h
jz retrun
push ax
xor ax,ax
call int16
pop ax
retrun: iret
newint09: push ax
in al,60h
cmp al,1dh
jnz k1
mov cs:byte ptr ctrl,0ffh
k1: cmp al,9dh
jnz k2
mov cs:byte ptr ctrl,00h
k2: cmp al,14h
jnz k3
mov cs:byte ptr keyt,0ffh
k3: cmp al,94h
jnz k4
mov cs:byte ptr keyt,00h
k4: cmp cs:byte ptr ctrl,0ffh
jnz k5
cmp cs:byte ptr keyt,0ffh
jnz k5
cmp cs:byte ptr exec,0ffh
jz k5
in al,61h
or al,80h
out 61h,al
and al,7fh
out 61h,al
mov al,20h
out 20h,al
pop ax
call main
iret
k5: pop ax
jmp cs:oldint09
procession: call saveregs
mov cs:byte ptr bufover,00h
mov al,cs:endf
cmp al,cs:dispf
jnz fillbuf0
mov cs:byte ptr bufover,0ffh
inc cs:byte ptr dispf
fillbuf0: cmp al,cs:beginf
jnz fillbuf
inc cs:byte ptr beginf
fillbuf: inc cs:byte ptr endf
xor ah,ah
mov cl,05h
shl ax,cl
mov di,ax
mov si,offset regsbuf
push cs
pop ds
mov ax,seg data2
mov es,ax
mov cx,20h
cld
rep movsb
cmp cs:byte ptr display,0ffh
jnz oops
mov di,offset regsbuf
push cs
pop es
call dispmsg
oops: call oopsregs
cmp cs:byte ptr bufover,0ffh
jz execmain
ret
execmain: call main
ret
dispmsg: push cs
pop ds
mov si,offset msg2
mov cx,8
dispmsg2: call dispregs
loop dispmsg2
call dispstring
mov al,es:[di]
inc di
call dispaL
mov al,es:[di]
inc di
cmp al,00h
jnz dispmsg0
call dispstring
add si,09
jmp dispmsg1
dispmsg0: add si,09
call dispstring
dispmsg1: mov cx,05
dispmsg3: call dispregs
loop dispmsg3
mov bx,es:[di]
test bx,10000000000b
jz df0
add si,4
call dispstring
jmp df1
df0: call dispstring
add si,4
df1: test bx,010000000000b
jz df2
add si,4
call dispstring
jmp df3
df2: call dispstring
add si,4
df3: test bx,100000000b
jz df4
add si,4
call dispstring
jmp df5
df4: call dispstring
add si,4
df5: test bx,10000000b
jz df6
add si,4
call dispstring
jmp df7
df6: call dispstring
add si,4
df7: test bx,1000000b
jz df8
add si,4
call dispstring
jmp df9
df8: call dispstring
add si,4
df9: test bx,10000b
jz df10
add si,4
call dispstring
jmp df11
df10: call dispstring
add si,4
df11: test bx,100b
jz df12
add si,4
call dispstring
jmp df13
df12: call dispstring
add si,4
df13: test bx,01b
jz df14
add si,4
call dispstring
jmp df15
df14: call dispstring
add si,4
df15: call dispregs
call dispregs
call dispstring
ret
dispstring: cld
lodsb
cmp al,0
jz disps0
call dispa
jmp dispstring
disps0: ret
dispregs: call dispstring
mov al,es:[di+1]
call dispaL
mov al,es:[di]
inc di
inc di
call dispal
ret
dispal: push ax
shr al,1
shr al,1
shr al,1
shr al,1
cmp al,9
ja dispal0
add al,'0'-'A'+10
dispal0: add al,'A'-10
call dispa
pop ax
push ax
and al,0fh
cmp al,9
ja dispal1
add al,'0'-'A'+10
dispal1: add al,'A'-10
call dispa
pop ax
ret
dispa: push ax
mov ah,0eh
int 10h
pop ax
ret
main: call saveregs
mov ah,0fh
int 10h
mov cs:typemodel,al
cmp al,03h
jz savecon
mov ax,03h
int 10h
savecon: mov ah,03h
xor bh,bh
int 10h
mov cs:pos,dx
mov ax,0b800h
mov ds,ax
mov ax,0b900h
mov es,ax
xor di,di
xor si,si
mov cx,4000d
cld
rep movsb
rk10: call clscon
rk0: call dispmain
call dispmsg12
xor ax,ax
call int16
cmp ah,2fh
jnz rk1
call set
jmp rk10
rk1: cmp ah,1fh
jnz rk2
call search
jmp rk10
rk2: cmp ah,2eh
jnz rk3
xor cs:byte ptr display,0ffh
jmp rk0
rk3: cmp ah,25h
jnz rk4
xor cs:byte ptr key,0ffh
jmp rk0
rk4: cmp ah,14h
jnz rk5
xor cs:byte ptr trapfg,0ffh
jmp rk0
rk5: cmp ah,17h
jnz rk6
xor cs:byte ptr input,0ffh
jmp rk0
rk6: cmp ah,18h
jnz rk7
xor cs:byte ptr output,0ffh
jmp rk0
rk7: cmp ah,23h
jnz rk8
call help
jmp rk0
rk8: cmp ah,1eh
jnz rk9
call abort
jmp rk0
rk9: cmp ah,10h
jz oopscon
cmp ah,01h
jz oopscon
jmp rk0
oopscon: cmp cs:typemodel,03h
jz oopscon0
mov al,cs:typemodel
xor ah,ah
int 10h
jmp oopscon1
oopscon0: mov ax,0b800h
mov es,ax
mov ax,0b900h
mov ds,ax
xor di,di
xor si,si
mov cx,4000d
cld
rep movsb
oopscon1: mov dx,cs:pos
mov ah,02
xor bh,bh
int 10h
call oopsregs
ret
help: mov si,offset msg10
help0: mov dx,0400h
mov ah,02h
xor bh,bh
int 10h
push cs
pop ds
call dispstring
ret
abort: mov si,offset msg11
jmp help0
set: call dispmsg13
mov dx,0b00h
xor bh,bh
mov ah,02h
int 10h
push cs
pop ds
mov si,offset msg3
call dispstring
xor dx,dx
set2: push dx
mov dx,0c00h
mov ah,02h
xor bh,bh
int 10h
pop dx
mov cx,08
mov dl,dh
set1: push cx
push dx
mov al,dl
call dispal
mov cx,9
set0: mov al,20h
call dispa
loop set0
mov al,dl
xor ah,ah
shl ax,1
shl ax,1
mov di,ax
xor ax,ax
mov es,ax
mov al,es:[di+3] ;fixed
call dispal
mov al,es:[di+2]
call dispal
mov al,':'
call dispa
mov al,es:[di+1]
call dispal
mov al,es:[di]
call dispal
mov ax,seg data1
mov es,ax
xor ax,ax
cmp es:[di],ax
jnz set5
cmp es:[di+2],ax
jnz set5
call dispnotrap
jmp set6
set5: call disptraped
set6: pop dx
pop cx
inc dl
loop set1
xor ax,ax
call int16
cmp ah,1ch
jnz set7
call set3
jmp set2
set7: cmp ah,01h
jnz set8
ret
set8: cmp ah,48h
jnz set9
dec dh
jmp set2
set9: cmp ah,50h
jnz set10
inc dh
jmp set2
set10: cmp ah,49h
jnz set11
sub dh,08h
jmp set2
set11: cmp ah,51h
jnz set12
add dh,08h
set12: jmp set2
set3: mov al,dh
xor ah,ah
shl ax,1
shl ax,1
mov di,ax
mov ax,seg data1
mov es,ax
mov si,di
xor ax,ax
mov ds,ax
cmp es:byte ptr[si],00h
jnz set4
cmp es:byte ptr[si+2],00h
jnz set4
cld
push si
cli
movsw
movsw
mov ax,cs
sub al,dh
sbb ah,0
pop si
mov ds:[si+2],ax
mov al,dh
xor ah,ah
mov cl,04
shl ax,cl
mov ds:[si],ax
sti
ret
set4: push es
push ds
pop es
pop ds
cld
cli
push si
movsw
movsw
sti
xor ax,ax
pop si
mov ds:[si],ax
mov ds:[si+2],ax
ret
dispmain: mov dx,0100h
xor bh,bh
mov ah,02h
int 10h
push cs
pop ds
mov si,offset msg8
call dispstring
cmp cs:byte ptr display,00h
jnz dispmain0
call dispoff
jmp dispmain1
dispmain0: call dispon
dispmain1: call dispstring
cmp cs:byte ptr key,00h
jnz dispmain2
call dispoff
jmp dispmain3
dispmain2: call dispon
dispmain3: call dispstring
cmp cs:byte ptr trapfg,00h
jnz dispmain4
call dispoff
jmp dispmain5
dispmain4: call dispon
dispmain5: call dispstring
cmp cs:byte ptr input,00h
jnz dispmain6
call dispoff
jmp dispmain7
dispmain6: call dispon
dispmain7: call dispstring
cmp cs:byte ptr output,00h
jnz dispmain8
call dispoff
jmp dispmain9
dispmain8: call dispon
dispmain9: call dispstring
ret
search: call dispmsg14
mov dx,0400h
xor bh,bh
mov ah,02h
int 10h
mov cx,05
mov dl,cs:dispf
inc dl
search0: push cx
push dx
cmp dl,cs:endf
jnz search1
push cs
pop ds
mov si,offset msg9
call dispstring
pop dx
pop cx
loop search0
jmp search3
search1: mov al,32
mul dl
mov di,ax
mov ax,seg data2
mov es,ax
call dispmsg
search2: pop dx
inc dl
pop cx
loop search0
search3: xor ah,ah
call int16
cmp ah,48h
jnz search4
call decdispf
jmp search
search4: cmp ah,50h
jnz search5
call incdispf
jmp search
search5: cmp ah,49h
jnz search6
mov cx,05h
decdf: call decdispf
loop decdf
jmp search
search6: cmp ah,51h
jnz search7
mov cx,05h
incdf: call incdispf
loop incdf
jmp search
search7: cmp ah,01h
jnz search8
ret
search8: jmp search3
decdispf: mov dl,cs:dispf
cmp dl,cs:beginf
jz decdispf0
dec cs:byte ptr dispf
decdispf0: ret
incdispf: mov dl,cs:dispf
inc dl
cmp dl,cs:endf
jz incdispf0
inc cs:byte ptr dispf
incdispf0: ret
disptraped: push ds
push si
push cs
pop ds
mov si,offset msg4
call dispstring
pop si
pop ds
ret
dispnotrap: push ds
push si
push cs
pop ds
mov si,offset msg5
call dispstring
pop si
pop ds
ret
dispoff: push ds
push si
push cs
pop ds
mov si,offset msg6
call dispstring
pop si
pop ds
ret
dispon: push ds
push si
push cs
pop ds
mov si,offset msg7
call dispstring
pop si
pop ds
ret
int16: pushf
cli
call cs:oldint16
ret
clscon: mov ax,0600h
mov cx,0
mov dx,24*256+79d
mov bh,06h
int 10h
ret
dispmsg12: mov si,offset msg12
jmp dispmsg121314
dispmsg13: mov si,offset msg13
jmp dispmsg121314
dispmsg14: mov si,offset msg14
jmp dispmsg121314
dispmsg121314: mov dx,1500h
xor bh,bh
mov ah,02h
int 10h
push cs
pop ds
call dispstring
ret
saveregs: mov cs:byte ptr exec,0ffh
pop cs:backaddress
mov cs:regax,ax
mov cs:regbx,bx
mov cs:regcx,cx
mov cs:regdx,dx
mov bx,sp
mov ax,ss:[bx+2]
mov cs:regip,ax
mov ax,ss:[bx+4]
mov cs:regcs,ax
mov ax,ss:[bx+6]
mov cs:regfg,ax
mov cs:regsp,sp
mov cs:regbp,bp
mov cs:regsi,si
mov cs:regdi,di
mov cs:regds,ds
mov cs:reges,es
mov cs:regss,ss
cli
mov ax,seg stack
mov ss,ax
mov sp,offset stackend
sti
push cs:backaddress
ret
oopsregs: cli
pop cs:backaddress
mov ax,cs:regax
mov bx,cs:regbx
mov cx,cs:regcx
mov dx,cs:regdx
mov sp,cs:regsp
mov bp,cs:regbp
mov si,cs:regsi
mov di,cs:regdi
mov ds,cs:regds
mov es,cs:reges
mov ss,cs:regss
push cs:backaddress
mov cs:byte ptr exec,00h
ret
typemodel db ?
pos dw ?
endf db 01
dispf db 0
beginf db 0
bufover db ?
backaddress dw ?
exec db 0
input db 0ffh
output db 00h
key db 0
display db 0ffh
ctrl db 0
keyt db 0
trapfg db 0
oldint09 dd ?
oldint16 dd ?
regsbuf:
regax dw ?
regbx dw ?
regcx dw ?
regdx dw ?
regsp dw ?
regbp dw ?
regsi dw ?
regdi dw ?
intcode db ?
intflag db ?
regds dw ?
reges dw ?
regss dw ?
regcs dw ?
regip dw ?
regfg dw ?
intnumber dw 00h
msg2 db 0dh,0ah
db 'AX=',0,' BX=',0,' CX=',0,' DX=',0,' SP=',0,' BP=',0,' SI=',0,' DI=',0
db ' Int=',0,' Input ',0,' Output',0
db 0dh,0ah
db 'DS=',0,' ES=',0,' SS=',0,' CS=',0,' IP=',0
db ' NY',0,' OY',0,' UP',0,' DN',0,' DI',0,' EI',0,' PL',0,' NG',0
db ' NZ',0,' ZR',0,' NA',0,' AC',0,' PO',0,' PE',0,' NC',0,' CY',0,' ',0
db ' No.',0,0dh,0ah,0,0
msg3 db 'IntCode*****Address***********Status ',0dh,0ah,0
msg4 db ' Traped... ',0dh,0ah,00
msg5 db ' No Trace ',0dh,0ah,00
msg6 db 'Off',00
msg7 db ' On',00
msg8 db 'Vector trace choose Search interrupt msg Con display ',0,' Key ',0
db 0dh,0ah
db 'Trace ',0,' Input messege ',0,' Output messege ',0,' Help Abort Quit'
db 0dh,0ah,0
msg9 db 0dh,0ah,79 dup(32),0dh,0ah,79 dup(32),0dh,0ah,0,0
msg10 db ' This program is used to trace interrupt of a program. ',0dh,0ah
db ' Operation step: ',0dh,0ah
db ' 1> Press the key <V> to choose interrupt. ',0dh,0ah
db ' 2> Press the key <T> open trace flag. ',0dh,0ah
db ' 3> press keys <C>,<K>,<I>,<O>,to set status. ',0dh,0ah
db ' 4> Exit main meun begin trap. ',0dh,0ah
db ' The key <S> can search the interrupt messege. ',0dh,0ah,0
msg11 db ' This program was wortten by ZhaoJiBin on 1999.9.10. ',0dh,0ah
db ' The following is my doc, Need into UCDOS... ',0dh,0ah
db ' 性名: 赵纪斌 ',0dh,0ah
db ' 学校名称: 四川工业学院 ',0dh,0ah
db ' 系别: 材料科学与工程系(铸造) 97级 ',0dh,0ah
db ' 现年年龄: 20岁 ',0dh,0ah
db ' 联系电话: (083)7721727 ',0dh,0ah,0
msg12 db '*********************************Main meun**********************************',0dh,0ah,0ah
db 'Current Operate: Key <V>,<S>,<C>,<K>,<T>,<I>,<O>,<H>,<A>To Work <Q>/Esc:Exit',0dh,0ah,0
msg13 db '***************************Vector Trace Choose******************************',0dh,0ah,0ah
db 'Current Operate: ,,PageUp,PageDown To Choose and Enter: setup,Esc:main....',0dh,0ah,0
msg14 db '**********************Search Interrupt Message******************************',0dh,0ah,0ah
db 'Current Operate: ,,PageUp,PageDown To Search Interrupt message,Esc:main...',0dh,0ah,0
codeend=$
data1 segment
db 256*5 dup(?)
data1end=$
data1 ends
data2 segment
db 256*33 dup(?)
data2end=$
data2 ends
stack segment stack 'stack'
assume cs:stack,ss:stack
start: mov ax,seg code
mov ds,ax
mov ax,3509h
int 21h
mov ds:word ptr oldint09,bx
mov ds:word ptr oldint09+2,es
mov ax,3516h
int 21h
mov ds:word ptr oldint16,bx
mov ds:word ptr oldint16+2,es
mov ax,2509h
mov dx,offset newint09
int 21h
push cs
pop ds
mov dx,offset msg1
mov ah,09h
int 21h
mov ax,3100h
mov dx,400h
int 21h
msg1: db 0dh,0ah,' Press Ctrl+T into main meun....$'
org 200h
stackend:
stack ends
end start
code segment
assume cs:code
trace: push ax
call far ptr saveintcode
saveintcode: pop ax
shr ax,1
shr ax,1
shr ax,1
shr ax,1
mov cs:intcode,al
pop ax
pop ax
cmp cs:byte ptr exec,0ffh
jz calloldint
cmp cs:byte ptr trapfg,0
jz calloldint
inc cs:word ptr intnumber
mov cs:byte ptr intflag,0
cmp cs:byte ptr input,0
jz calloldint
call procession
cmp cs:byte ptr key,00h
jz calloldint
push ax
xor ax,ax
call int16
pop ax
calloldint: push ax
push bx
push ds
mov bl,cs:intcode
xor bh,bh
shl bx,1
shl bx,1
mov ax,seg data1
mov ds,ax
mov ax,ds:[bx]
mov cs:word ptr oldint,ax
mov ax,ds:[bx+2]
mov cs:word ptr oldint+2,ax
mov bx,sp
mov ax,ss:[bx+0ah]
xchg ax,ss:[bx+4h]
pop ds
pop bx
cli
jmp oldintcall
oldintcall: db 09ah
oldint dd ?
push ax
push bx
pushf
cli
pop ax
mov bx,sp
mov ss:[bx+8h],ax
pop bx
pop ax
cmp cs:byte ptr exec,0ffh
jz retrun
cmp cs:byte ptr trapfg,0
jz retrun
mov cs:byte ptr intflag,0ffh
cmp cs:byte ptr output,00h
jz retrun
call procession
cmp cs:byte ptr key,00h
jz retrun
push ax
xor ax,ax
call int16
pop ax
retrun: iret
newint09: push ax
in al,60h
cmp al,1dh
jnz k1
mov cs:byte ptr ctrl,0ffh
k1: cmp al,9dh
jnz k2
mov cs:byte ptr ctrl,00h
k2: cmp al,14h
jnz k3
mov cs:byte ptr keyt,0ffh
k3: cmp al,94h
jnz k4
mov cs:byte ptr keyt,00h
k4: cmp cs:byte ptr ctrl,0ffh
jnz k5
cmp cs:byte ptr keyt,0ffh
jnz k5
cmp cs:byte ptr exec,0ffh
jz k5
in al,61h
or al,80h
out 61h,al
and al,7fh
out 61h,al
mov al,20h
out 20h,al
pop ax
call main
iret
k5: pop ax
jmp cs:oldint09
procession: call saveregs
mov cs:byte ptr bufover,00h
mov al,cs:endf
cmp al,cs:dispf
jnz fillbuf0
mov cs:byte ptr bufover,0ffh
inc cs:byte ptr dispf
fillbuf0: cmp al,cs:beginf
jnz fillbuf
inc cs:byte ptr beginf
fillbuf: inc cs:byte ptr endf
xor ah,ah
mov cl,05h
shl ax,cl
mov di,ax
mov si,offset regsbuf
push cs
pop ds
mov ax,seg data2
mov es,ax
mov cx,20h
cld
rep movsb
cmp cs:byte ptr display,0ffh
jnz oops
mov di,offset regsbuf
push cs
pop es
call dispmsg
oops: call oopsregs
cmp cs:byte ptr bufover,0ffh
jz execmain
ret
execmain: call main
ret
dispmsg: push cs
pop ds
mov si,offset msg2
mov cx,8
dispmsg2: call dispregs
loop dispmsg2
call dispstring
mov al,es:[di]
inc di
call dispaL
mov al,es:[di]
inc di
cmp al,00h
jnz dispmsg0
call dispstring
add si,09
jmp dispmsg1
dispmsg0: add si,09
call dispstring
dispmsg1: mov cx,05
dispmsg3: call dispregs
loop dispmsg3
mov bx,es:[di]
test bx,10000000000b
jz df0
add si,4
call dispstring
jmp df1
df0: call dispstring
add si,4
df1: test bx,010000000000b
jz df2
add si,4
call dispstring
jmp df3
df2: call dispstring
add si,4
df3: test bx,100000000b
jz df4
add si,4
call dispstring
jmp df5
df4: call dispstring
add si,4
df5: test bx,10000000b
jz df6
add si,4
call dispstring
jmp df7
df6: call dispstring
add si,4
df7: test bx,1000000b
jz df8
add si,4
call dispstring
jmp df9
df8: call dispstring
add si,4
df9: test bx,10000b
jz df10
add si,4
call dispstring
jmp df11
df10: call dispstring
add si,4
df11: test bx,100b
jz df12
add si,4
call dispstring
jmp df13
df12: call dispstring
add si,4
df13: test bx,01b
jz df14
add si,4
call dispstring
jmp df15
df14: call dispstring
add si,4
df15: call dispregs
call dispregs
call dispstring
ret
dispstring: cld
lodsb
cmp al,0
jz disps0
call dispa
jmp dispstring
disps0: ret
dispregs: call dispstring
mov al,es:[di+1]
call dispaL
mov al,es:[di]
inc di
inc di
call dispal
ret
dispal: push ax
shr al,1
shr al,1
shr al,1
shr al,1
cmp al,9
ja dispal0
add al,'0'-'A'+10
dispal0: add al,'A'-10
call dispa
pop ax
push ax
and al,0fh
cmp al,9
ja dispal1
add al,'0'-'A'+10
dispal1: add al,'A'-10
call dispa
pop ax
ret
dispa: push ax
mov ah,0eh
int 10h
pop ax
ret
main: call saveregs
mov ah,0fh
int 10h
mov cs:typemodel,al
cmp al,03h
jz savecon
mov ax,03h
int 10h
savecon: mov ah,03h
xor bh,bh
int 10h
mov cs:pos,dx
mov ax,0b800h
mov ds,ax
mov ax,0b900h
mov es,ax
xor di,di
xor si,si
mov cx,4000d
cld
rep movsb
rk10: call clscon
rk0: call dispmain
call dispmsg12
xor ax,ax
call int16
cmp ah,2fh
jnz rk1
call set
jmp rk10
rk1: cmp ah,1fh
jnz rk2
call search
jmp rk10
rk2: cmp ah,2eh
jnz rk3
xor cs:byte ptr display,0ffh
jmp rk0
rk3: cmp ah,25h
jnz rk4
xor cs:byte ptr key,0ffh
jmp rk0
rk4: cmp ah,14h
jnz rk5
xor cs:byte ptr trapfg,0ffh
jmp rk0
rk5: cmp ah,17h
jnz rk6
xor cs:byte ptr input,0ffh
jmp rk0
rk6: cmp ah,18h
jnz rk7
xor cs:byte ptr output,0ffh
jmp rk0
rk7: cmp ah,23h
jnz rk8
call help
jmp rk0
rk8: cmp ah,1eh
jnz rk9
call abort
jmp rk0
rk9: cmp ah,10h
jz oopscon
cmp ah,01h
jz oopscon
jmp rk0
oopscon: cmp cs:typemodel,03h
jz oopscon0
mov al,cs:typemodel
xor ah,ah
int 10h
jmp oopscon1
oopscon0: mov ax,0b800h
mov es,ax
mov ax,0b900h
mov ds,ax
xor di,di
xor si,si
mov cx,4000d
cld
rep movsb
oopscon1: mov dx,cs:pos
mov ah,02
xor bh,bh
int 10h
call oopsregs
ret
help: mov si,offset msg10
help0: mov dx,0400h
mov ah,02h
xor bh,bh
int 10h
push cs
pop ds
call dispstring
ret
abort: mov si,offset msg11
jmp help0
set: call dispmsg13
mov dx,0b00h
xor bh,bh
mov ah,02h
int 10h
push cs
pop ds
mov si,offset msg3
call dispstring
xor dx,dx
set2: push dx
mov dx,0c00h
mov ah,02h
xor bh,bh
int 10h
pop dx
mov cx,08
mov dl,dh
set1: push cx
push dx
mov al,dl
call dispal
mov cx,9
set0: mov al,20h
call dispa
loop set0
mov al,dl
xor ah,ah
shl ax,1
shl ax,1
mov di,ax
xor ax,ax
mov es,ax
mov al,es:[di+3] ;fixed
call dispal
mov al,es:[di+2]
call dispal
mov al,':'
call dispa
mov al,es:[di+1]
call dispal
mov al,es:[di]
call dispal
mov ax,seg data1
mov es,ax
xor ax,ax
cmp es:[di],ax
jnz set5
cmp es:[di+2],ax
jnz set5
call dispnotrap
jmp set6
set5: call disptraped
set6: pop dx
pop cx
inc dl
loop set1
xor ax,ax
call int16
cmp ah,1ch
jnz set7
call set3
jmp set2
set7: cmp ah,01h
jnz set8
ret
set8: cmp ah,48h
jnz set9
dec dh
jmp set2
set9: cmp ah,50h
jnz set10
inc dh
jmp set2
set10: cmp ah,49h
jnz set11
sub dh,08h
jmp set2
set11: cmp ah,51h
jnz set12
add dh,08h
set12: jmp set2
set3: mov al,dh
xor ah,ah
shl ax,1
shl ax,1
mov di,ax
mov ax,seg data1
mov es,ax
mov si,di
xor ax,ax
mov ds,ax
cmp es:byte ptr[si],00h
jnz set4
cmp es:byte ptr[si+2],00h
jnz set4
cld
push si
cli
movsw
movsw
mov ax,cs
sub al,dh
sbb ah,0
pop si
mov ds:[si+2],ax
mov al,dh
xor ah,ah
mov cl,04
shl ax,cl
mov ds:[si],ax
sti
ret
set4: push es
push ds
pop es
pop ds
cld
cli
push si
movsw
movsw
sti
xor ax,ax
pop si
mov ds:[si],ax
mov ds:[si+2],ax
ret
dispmain: mov dx,0100h
xor bh,bh
mov ah,02h
int 10h
push cs
pop ds
mov si,offset msg8
call dispstring
cmp cs:byte ptr display,00h
jnz dispmain0
call dispoff
jmp dispmain1
dispmain0: call dispon
dispmain1: call dispstring
cmp cs:byte ptr key,00h
jnz dispmain2
call dispoff
jmp dispmain3
dispmain2: call dispon
dispmain3: call dispstring
cmp cs:byte ptr trapfg,00h
jnz dispmain4
call dispoff
jmp dispmain5
dispmain4: call dispon
dispmain5: call dispstring
cmp cs:byte ptr input,00h
jnz dispmain6
call dispoff
jmp dispmain7
dispmain6: call dispon
dispmain7: call dispstring
cmp cs:byte ptr output,00h
jnz dispmain8
call dispoff
jmp dispmain9
dispmain8: call dispon
dispmain9: call dispstring
ret
search: call dispmsg14
mov dx,0400h
xor bh,bh
mov ah,02h
int 10h
mov cx,05
mov dl,cs:dispf
inc dl
search0: push cx
push dx
cmp dl,cs:endf
jnz search1
push cs
pop ds
mov si,offset msg9
call dispstring
pop dx
pop cx
loop search0
jmp search3
search1: mov al,32
mul dl
mov di,ax
mov ax,seg data2
mov es,ax
call dispmsg
search2: pop dx
inc dl
pop cx
loop search0
search3: xor ah,ah
call int16
cmp ah,48h
jnz search4
call decdispf
jmp search
search4: cmp ah,50h
jnz search5
call incdispf
jmp search
search5: cmp ah,49h
jnz search6
mov cx,05h
decdf: call decdispf
loop decdf
jmp search
search6: cmp ah,51h
jnz search7
mov cx,05h
incdf: call incdispf
loop incdf
jmp search
search7: cmp ah,01h
jnz search8
ret
search8: jmp search3
decdispf: mov dl,cs:dispf
cmp dl,cs:beginf
jz decdispf0
dec cs:byte ptr dispf
decdispf0: ret
incdispf: mov dl,cs:dispf
inc dl
cmp dl,cs:endf
jz incdispf0
inc cs:byte ptr dispf
incdispf0: ret
disptraped: push ds
push si
push cs
pop ds
mov si,offset msg4
call dispstring
pop si
pop ds
ret
dispnotrap: push ds
push si
push cs
pop ds
mov si,offset msg5
call dispstring
pop si
pop ds
ret
dispoff: push ds
push si
push cs
pop ds
mov si,offset msg6
call dispstring
pop si
pop ds
ret
dispon: push ds
push si
push cs
pop ds
mov si,offset msg7
call dispstring
pop si
pop ds
ret
int16: pushf
cli
call cs:oldint16
ret
clscon: mov ax,0600h
mov cx,0
mov dx,24*256+79d
mov bh,06h
int 10h
ret
dispmsg12: mov si,offset msg12
jmp dispmsg121314
dispmsg13: mov si,offset msg13
jmp dispmsg121314
dispmsg14: mov si,offset msg14
jmp dispmsg121314
dispmsg121314: mov dx,1500h
xor bh,bh
mov ah,02h
int 10h
push cs
pop ds
call dispstring
ret
saveregs: mov cs:byte ptr exec,0ffh
pop cs:backaddress
mov cs:regax,ax
mov cs:regbx,bx
mov cs:regcx,cx
mov cs:regdx,dx
mov bx,sp
mov ax,ss:[bx+2]
mov cs:regip,ax
mov ax,ss:[bx+4]
mov cs:regcs,ax
mov ax,ss:[bx+6]
mov cs:regfg,ax
mov cs:regsp,sp
mov cs:regbp,bp
mov cs:regsi,si
mov cs:regdi,di
mov cs:regds,ds
mov cs:reges,es
mov cs:regss,ss
cli
mov ax,seg stack
mov ss,ax
mov sp,offset stackend
sti
push cs:backaddress
ret
oopsregs: cli
pop cs:backaddress
mov ax,cs:regax
mov bx,cs:regbx
mov cx,cs:regcx
mov dx,cs:regdx
mov sp,cs:regsp
mov bp,cs:regbp
mov si,cs:regsi
mov di,cs:regdi
mov ds,cs:regds
mov es,cs:reges
mov ss,cs:regss
push cs:backaddress
mov cs:byte ptr exec,00h
ret
typemodel db ?
pos dw ?
endf db 01
dispf db 0
beginf db 0
bufover db ?
backaddress dw ?
exec db 0
input db 0ffh
output db 00h
key db 0
display db 0ffh
ctrl db 0
keyt db 0
trapfg db 0
oldint09 dd ?
oldint16 dd ?
regsbuf:
regax dw ?
regbx dw ?
regcx dw ?
regdx dw ?
regsp dw ?
regbp dw ?
regsi dw ?
regdi dw ?
intcode db ?
intflag db ?
regds dw ?
reges dw ?
regss dw ?
regcs dw ?
regip dw ?
regfg dw ?
intnumber dw 00h
msg2 db 0dh,0ah
db 'AX=',0,' BX=',0,' CX=',0,' DX=',0,' SP=',0,' BP=',0,' SI=',0,' DI=',0
db ' Int=',0,' Input ',0,' Output',0
db 0dh,0ah
db 'DS=',0,' ES=',0,' SS=',0,' CS=',0,' IP=',0
db ' NY',0,' OY',0,' UP',0,' DN',0,' DI',0,' EI',0,' PL',0,' NG',0
db ' NZ',0,' ZR',0,' NA',0,' AC',0,' PO',0,' PE',0,' NC',0,' CY',0,' ',0
db ' No.',0,0dh,0ah,0,0
msg3 db 'IntCode*****Address***********Status ',0dh,0ah,0
msg4 db ' Traped... ',0dh,0ah,00
msg5 db ' No Trace ',0dh,0ah,00
msg6 db 'Off',00
msg7 db ' On',00
msg8 db 'Vector trace choose Search interrupt msg Con display ',0,' Key ',0
db 0dh,0ah
db 'Trace ',0,' Input messege ',0,' Output messege ',0,' Help Abort Quit'
db 0dh,0ah,0
msg9 db 0dh,0ah,79 dup(32),0dh,0ah,79 dup(32),0dh,0ah,0,0
msg10 db ' This program is used to trace interrupt of a program. ',0dh,0ah
db ' Operation step: ',0dh,0ah
db ' 1> Press the key <V> to choose interrupt. ',0dh,0ah
db ' 2> Press the key <T> open trace flag. ',0dh,0ah
db ' 3> press keys <C>,<K>,<I>,<O>,to set status. ',0dh,0ah
db ' 4> Exit main meun begin trap. ',0dh,0ah
db ' The key <S> can search the interrupt messege. ',0dh,0ah,0
msg11 db ' This program was wortten by ZhaoJiBin on 1999.9.10. ',0dh,0ah
db ' The following is my doc, Need into UCDOS... ',0dh,0ah
db ' 性名: 赵纪斌 ',0dh,0ah
db ' 学校名称: 四川工业学院 ',0dh,0ah
db ' 系别: 材料科学与工程系(铸造) 97级 ',0dh,0ah
db ' 现年年龄: 20岁 ',0dh,0ah
db ' 联系电话: (083)7721727 ',0dh,0ah,0
msg12 db '*********************************Main meun**********************************',0dh,0ah,0ah
db 'Current Operate: Key <V>,<S>,<C>,<K>,<T>,<I>,<O>,<H>,<A>To Work <Q>/Esc:Exit',0dh,0ah,0
msg13 db '***************************Vector Trace Choose******************************',0dh,0ah,0ah
db 'Current Operate: ,,PageUp,PageDown To Choose and Enter: setup,Esc:main....',0dh,0ah,0
msg14 db '**********************Search Interrupt Message******************************',0dh,0ah,0ah
db 'Current Operate: ,,PageUp,PageDown To Search Interrupt message,Esc:main...',0dh,0ah,0
codeend=$
data1 segment
db 256*5 dup(?)
data1end=$
data1 ends
data2 segment
db 256*33 dup(?)
data2end=$
data2 ends
stack segment stack 'stack'
assume cs:stack,ss:stack
start: mov ax,seg code
mov ds,ax
mov ax,3509h
int 21h
mov ds:word ptr oldint09,bx
mov ds:word ptr oldint09+2,es
mov ax,3516h
int 21h
mov ds:word ptr oldint16,bx
mov ds:word ptr oldint16+2,es
mov ax,2509h
mov dx,offset newint09
int 21h
push cs
pop ds
mov dx,offset msg1
mov ah,09h
int 21h
mov ax,3100h
mov dx,400h
int 21h
msg1: db 0dh,0ah,' Press Ctrl+T into main meun....$'
org 200h
stackend:
stack ends
end start
相关文章推荐
- Java静态代码分析工具——FindBugs插件的安装与使用
- 代码分析工具 cppcheck 使用介绍
- .NET性能分析最佳实践之:如何找出使用过多内存的.NET代码(基础篇)
- 如何使用VSTS工具来分析软件的代码和性能?
- 让开发自动化持续重构 --使用静态分析工具识别代码味道
- 代码分析工具findbug简介和使用
- IE调试网页之七:使用探查器工具分析代码性能 (Windows)
- linux中断底半部之 softirq 原理与代码分析
- 代码静态分析工具——splint的学习与使用(转)
- Android平台APK分析工具包androguard的部署使用和原理分析
- 关于mini2440启动代码中中断的产生原理分析
- .NET : 使用代码性能分析工具
- 代码静态分析工具——splint的学习与使用
- 使用代码分析工具分析应用程序质量【鸡蛋】
- 堆调试工具——pageheap的使用和原理分析
- 代码静态分析工具——splint的学习与使用
- 如何使用VSTS工具来分析软件的代码和性能?
- .NET性能分析最佳实践之:如何找出使用过多内存的.NET代码(进阶篇)
- Https与Http,SSL,DevOps, 静态代码分析工具,RFID, SSH, 非对称加密算法(使用最广泛的一种是RSA), 数字签名, 数字证书
- 堆调试工具——pageheap的使用和原理分析