概述
Code SEGMENT
ASSUME cs:Code
ORG 2CH
EVBSeg dw ?
ORG 80H
Count db ?
CmdStr label byte
ORG 100H
Start:
JMP Init
Flag db 'STT XM-ZDH',123,'STT'
old1c dd 0
old09 dd 0
InDos dd ?
BuffOK db 0 ;if BuffOK THEN Write TO FILE
busy db 0
int1c PROC
pushf
call cs:old1c
sti
pushf
cmp cs:busy,0
jnz @601
push ax
mov al,0ffh
mov cs:busy,al
cmp cs:BuffOK,0
jz @602
call ToFile
@602:
mov al,0
mov cs:busy,al
pop ax
@601:
popf
iret
int1c ENDP
ToFile PROC
push bx
push cx
push dx
push si
push di
push es
push ds
push cs
pop ds
les bx,InDos
mov al,byte ptr es:[bx]
cmp al,0
jnz @611
call StartToFile
mov al,0
mov cs:BuffOK,al
@611:
pop ds
pop es
pop di
pop si
pop dx
pop cx
pop bx
ret
ToFile ENDP
StartToFile PROC
call CreateFile
cmp ax,ax
jnz @t51
call WriteFile
call CloseFile
@t51:
ret
StartToFile ENDP
int09 PROC
pushf
call cs:old09
sti
pushf
cmp cs:busy,0
jnz @401
push ax
mov al,0ffh
mov byte ptr cs:busy,al
cmp cs:BuffOK,0
jnz @402
mov ah,2
int 16h
and al,3
cmp al,3
jnz @402
call GetScrBuff
mov al,0ffh
mov byte ptr cs:BuffOK,al
@402:
mov al,0
mov byte ptr cs:busy,al
pop ax
@401:
popf
iret
int09 ENDP
GetScrBuff PROC
push ds
push es
push bx
push si
mov bx,0b800h
mov es,bx
push cs
pop ds
mov si,offset ScrBuff
xor bx,bx
@503:
cmp bx,4000
jb @501
jmp @502
@501:
mov al,byte ptr es:[bx]
cmp al,0
jnz @511
mov al,' '
@511:
mov byte ptr ds:[si],al
inc bx
inc bx
inc si
jmp @503
@502:
pop si
pop bx
pop es
pop ds
ret
GetScrBuff ENDP
ScrBuff db 2000 dup(?)
ToChar PROC
and ah,0fh
cmp ah,10
jb @t01
add ah,55 ;55='A'-10
jmp @t02
@t01:
add ah,'0'
@t02:
ret
ToChar ENDP
XMFILE db 'XM'
NUMSTR db '0000'
EXT db '.TXT',0
XMNUM dw 0
Handle dw 0ffffh
ToFileName PROC
mov bx,offset NUMSTR
mov cx,XMNUM
mov ah,ch
shr ah,4
call ToChar
mov byte ptr [bx],ah
inc bx
mov ah,ch
call ToChar
mov byte ptr [bx],ah
inc bx
mov ah,cl
shr ah,4
call ToChar
mov byte ptr [bx],ah
inc bx
mov ah,cl
call ToChar
mov byte ptr [bx],ah
ret
ToFileName ENDP
GetFileName PROC
@t12:
call ToFileName
mov dx,offset XMFILE
xor cx,cx
mov ah,4eh
int 21h
jc @t11
mov ax,XMNUM
inc ax
mov XMNUM,ax
jmp @t12
@t11:
ret
GetFileName ENDP
CreateFile PROC
call GetFileName
mov dx,offset XMFILE
xor cx,cx
mov ah,3ch
int 21h
jc @t21
mov Handle,ax
xor ax,ax
jmp @t22
@t21:
mov ax,0ffffh
mov Handle,ax
@t22:
ret
CreateFile ENDP
LN db 0dh,0ah
WriteFile PROC
cmp Handle,0ffffh
jz @t31
mov di,offset ScrBuff
xor si,si
@t32:
cmp si,25
jnb @t31
call WriteLine
inc si
jmp @t32
@t31:
ret
WriteFile ENDP
WriteLine PROC
mov ax,si
mov cx,80
mul cl
add ax,di
mov bx,Handle
mov dx,ax
mov ah,40h
int 21h
mov cx,2
mov dx,offset LN
mov bx,Handle
mov ah,40h
int 21h
ret
WriteLine ENDP
CloseFile PROC
cmp Handle,0ffffh
jz @t41
mov bx,Handle
mov ah,3eh
int 21h
@t41:
ret
CloseFile ENDP
TSREnd label
Insted db 0 ;if TSR in memory then Insted<>0
AllocUnInst db 0 ;if AllocUnInst<>0 then Alloc Uninstall
Cmd db 0 ;if Cmd<>0 then Command Uninstall
Init PROC
mov dx,offset BEGIN
mov ah,9
int 21h
mov ah,34h
int 21h
mov word ptr InDos,bx
mov word ptr InDos[2],es
call GetVect
call GetCmd
call CheckInst
call CheckUnInst
cmp Cmd,0
jz @001
cmp Insted,0
jz @002
call UnInstall
jmp @003
@002:
mov dx,offset NotHaveTSR
mov ah,9
int 21h
jmp @003
@001:
cmp Insted,0
jnz @004
call Install
jmp @003
@004:
mov dx,offset Instedmess
mov ah,9
int 21h
jmp @003
@003:
.EXIT
Init ENDP
BEGIN db 'XM-ZDH Screen To TXT Version 1.01 Copyright (c) 1999.3 XMZDH-SOFTWARE',0dh,0ah,'$'
Help db 'Syntax: STT [/u]',0dh,0ah
db 'Options: /u =Uninstall This TSR',0dh,0ah,0dh,0ah,'$'
InstOK db 'Install XM-ZDH Screen To TXT TSR OK!',0dh,0ah
db '< Left Shift + Right Shift >',0dh,0ah,'$'
UnInstOK db 'Uninstall XM-ZDH Screen To TXT TSR OK!',0dh,0ah,'$'
Instedmess db 'XM-ZDH Screen To TXT TSR is Active in memory',0dh,0ah,'$'
NotHaveTSR db 'XM-ZDH Screen To TXT TSR is not Active in memory',0dh,0ah,'$'
UninstFail db 'Uninstall XM-ZDH Screen To TXT TSR Fail!',0dh,0ah,'$'
UnInstall PROC
cmp AllocUnInst,0
jz @301
push ds
mov ax,351ch
int 21h
mov ax,word ptr es:old09[2]
mov ds,ax
mov dx,word ptr es:old09
mov ax,2509h
int 21h
mov ax,word ptr es:old1c[2]
mov ds,ax
mov dx,word ptr es:old1c
mov ax,251ch
int 21h
pop ds
mov ah,49h
int 21h
mov dx,offset UnInstOK
mov ah,9
int 21h
jmp @302
@301:
mov dx,offset UninstFail
mov ah,9
int 21h
@302:
ret
UnInstall ENDP
Install PROC
call FreeEVB
call SetVect
mov dx,offset InstOK
mov ah,9
int 21h
mov dx,offset TSREnd
inc dx
int 27h
ret
Install ENDP
CheckUnInst PROC
mov ax,word ptr old09[2]
mov bx,word ptr old1c[2]
cmp ax,bx
jnz @210
mov dl,0ffh
mov AllocUnInst,dl
@210:
ret
CheckUnInst ENDP
CheckInst PROC
mov bx,offset Flag
mov ax,word ptr old09[2]
call CmpStr
mov bx,offset Flag
mov ax,word ptr old1c[2]
call CmpStr
ret
CheckInst ENDP
CmpStr PROC
mov es,ax
mov cl,13
mov ch,0
@202:
cmp ch,cl
jnb @201
mov al,byte ptr ds:[bx]
mov ah,byte ptr es:[bx]
inc bx
inc ch
cmp al,ah
jz @202
jmp @203
@201:
mov dl,0ffh
mov Insted,dl
@203:
ret
CmpStr ENDP
GetCmd PROC
mov cl,Count
cmp cl,0
jz @101
mov bx,offset CmdStr
mov ch,0
@103:
cmp ch,cl
jnb @101
mov al,byte ptr DS:[bx]
inc ch
inc bx
@104:
cmp al,' '
jz @103
cmp al,'/'
jnz @103
mov al,byte ptr DS:[bx]
cmp al,'u'
jz @102
cmp al,'U'
jnz @103
@102:
mov dl,0ffh
mov Cmd,dl
jmp @110
@101:
mov dx,offset Help
mov ah,9
int 21h
@110:
ret
GetCmd ENDP
SetVect PROC
mov dx,offset int09
mov ax,2509h
int 21h
mov dx,offset int1c
mov ax,251ch
int 21h
ret
SetVect ENDP
GetVect PROC
mov ax,3509h
int 21h
mov word ptr old09,bx
mov word ptr old09[2],es
mov ax,351ch
int 21h
mov word ptr old1c,bx
mov word ptr old1c[2],es
ret
GetVect ENDP
FreeEVB PROC
mov ax,EVBSeg
mov es,ax
mov ah,49h
int 21h
ret
FreeEVB ENDP
Code ENDS
END Start
最后
以上就是刻苦樱桃为你收集整理的我在99年用汇编写的TSR程序的全部内容,希望文章能够帮你解决我在99年用汇编写的TSR程序所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复