;exam17 p310
;安装一个新的int7ch中断例程,实现通过逻辑扇区区号对软盘进行读写。
;参数说明:1.用ah寄存器传递功能号:0表示读,1表示写;
; 2.用dx寄存器传递要读写的扇区的逻辑扇区号;
; 3.用es:bx指向存储读出数据或写入数据的内存区;
assume cs:code
code segment
start:
mov ax,cs
mov ds,ax
mov si,offset int7ch
mov ax,0
mov es,ax
mov di,200h
mov cx,offset int7chend-offset int7ch
cld
rep movsb
mov word ptr es:[7ch*4],200h
mov word ptr es:[7ch*4+2],0
mov dx,100
mov al,2
mov ah,0;read
int 7ch
mov ax,4c00h
int 21h
int7ch:
push bx
push si
push ax
mov ax,0
mov es,ax
mov bx,2c8h
call s
pop ax
add ah,2
mov dl,0
int 13h
pop si
pop bx
iret
;-----------------call:dx ret:dh=mh,ch=cd,cl=sq-------------
s: push si
push ax
mov si,1440
call divs ;ljsq/1440 yushu=dx,shang=ax
push ax
mov si,18
call divs ;(ljsq/1440)/18 yushu=dx,shang=ax
mov ch,al;ch=cd
mov cl,dl
inc cl ;cl=sq
pop dx
mov dh,dl ;dh=mh
pop ax
pop si
ret
;-------------------------sub-pro,dx/si,dx=yushu,ax=shang
divs:
push dx
pop ax
mov dx,0
div si;dx/1440 yushu=dx,shang=ax
ret
int7chend:nop
code ends
end start |