改正后的源程序见下面:
popp macro
pop ds
pop es
pop di
pop si
pop dx
pop cx
pop bx
pop ax
popf
endm
;16进制数值转换为ACII码
hexasc macro
add al,090h
daa
adc al,040h
daa
endm
code segment
assume cs:code,ds:code
org 100h
be:
jmp init
buff db 0
dat db 'CH:'
ch1 db 0
ch2 db 0
db 'CL:'
cl1 db 0
cl2 db 0
db 'DH:'
dh1 db 0
dh2 db 0
mseg db '(请选择w/r/空格)'
oldint13 dd 0
newint13:
sti
pushf
push ax
push bx
push cx
push dx
push si
push di
push es
push ds
push cs
pop ds
cmp ah,03
jz jx1
jmp old
jx1:
cmp dl,80h
jz jx2
jmp old
jx2:
push cx
mov buff,ch
mov cl,4
mov al,buff
shr al,cl
hexasc
mov ch1,al
mov al,buff
and al,0fh
hexasc
mov ch2,al
pop cx
lea si,dat
mov ah,03h
mov bh,0
int 10h
push dx
mov dx,0029h
mov cx,34
loop1:
mov ah,02h
int 10h
mov bl,70h
mov ah,09h
lodsb
int 10h
inc dl
loop loop1
mov ah,02h
pop dx
int 10h
wait1:
mov ah,0
int 16h
cmp al,'w'
jz old
cmp al,'r'
jz rett
cmp al,' '
jnz wait1
cli
mov ah,4ch
int 21h
rett:
popp
cli
iret
old:
jmp cs:oldint13
init:
mov ax,3513h
int 21h
lea di,oldint13
mov [di],bx
mov [di+2],es
mov dx,offset newint13
mov ax,2513h
int 21h
mov dx,offset init
inc dx
int 27h
code ends
end be
[ Last edited by 本是 on 2007-1-6 at 03:57 AM ]作者: 本是 时间: 2007-1-6 03:57 程序的作用是:运行后驻留内存,并替换INT 13h磁盘处理中断,是写第1硬盘则询问w写、r读、空格则退回DOS(可改为不作任何磁盘操作而返回中断调用程序----删除行末有;;的行并改动提示信息为w to write hd0, r to read only)。
pushh macro
push ax
push bx
push cx
push dx
push si
push di
push es
push ds
endm
popp macro
pop ds
pop es
pop di
pop si
pop dx
pop cx
pop bx
pop ax
popf
endm
;16进制数值转换为ACII码
hexasc macro
add al,090h
daa
adc al,040h
daa
endm
code segment
assume cs:code,ds:code
org 100h
be:
jmp init
dat db 'CH:',0,0,'CL:',0,0,'DH:',0,0
mseg db 'Enter (w/r/SPACE):'
msglen=$-dat
hex2str:
add di,3
mov cl,4
mov al,bh
shr al,cl
hexasc
stosb
mov al,bh
and al,0fh
hexasc
stosb
ret
oldint13 dd 0
newint13:
sti
pushf
pushh
push cs
pop ds
cmp ah,03
jz jx1
jmp old
jx1:
cmp dl,80h
jz jx2
jmp old
jx2:
lea di,dat
push cx
mov bh,ch
call hex2str
pop cx
mov bh,cl
call hex2str
mov bh,dh
call hex2str
lea si,dat
mov ah,03h
mov bh,0
int 10h
push dx
mov dx,0029h
mov cx,msglen ;34
loop1:
mov ah,02h
int 10h
mov bl,70h
mov ah,09h
lodsb
int 10h
inc dl
loop loop1
mov ah,02h
pop dx
int 10h
wait1:
mov ah,0
int 16h
cmp al,'w'
jz old
cmp al,'W'
jz old
cmp al,'r'
jz rett
cmp al,'R'
jz rett ;;
cmp al,' ';;
jnz wait1
cli ;;
mov ah,4ch;;
int 21h ;;
rett:
popp
cli
iret
old:
jmp cs:oldint13
init:
mov ax,3513h
int 21h
lea di,oldint13
mov [di],bx
mov [di+2],es
mov dx,offset newint13
mov ax,2513h
int 21h
mov dx,offset init
inc dx
int 27h
code ends
end be
[ Last edited by 本是 on 2007-1-6 at 04:40 AM ]作者: 本是 时间: 2007-1-6 04:43 注意原INT 13h的中断向量并未保存,此程序仅供高手或虚拟机中使用,否则;)会“麻烦”!!!