17.4 Application int 13h interrupt routine disk read and write
3.5-inch floppy: 2 surface, 80 tracks / side, 18 sectors / track, 512 bytes / sector, Size: 1440KB≈1.44MB
Surface number, track number start from 0, 1 sector number from the beginning.
The contents of the current screen is saved on disk
the ASSUME CS: code code segment Start: MOV AX, 0b800h MOV ES, AX MOV BX, 0 MOV Al, . 8 ; the number of sectors written MOV CH, 0 ; track number MOV Cl, . 1 ; sector number MOV DL, 0 ; drive No. MOV DH, 0 ; head number (surface) MOV AH, 3 ; 2 read, write 3 int 13 is MOV AX, 4c00h int 21H code ends End Start
17 written test including functional subroutines interrupt routine
test program
assume cs:code code segment start: mov ah,0 mov dx,36 mov bx,0b800h mov es,bx mov bx,160*12+40*2 int 7ch mov ax,4c00h int 21h code ends end start
Interrupt routine
assume cs:code code segment start: mov ax,0 mov es,ax mov di,200h mov ax,cs mov ds,ax mov si,offset func mov cx,offset funcend-offset func cld rep movsb mov bx,0 mov es,bx mov word ptr es:[7ch*4],200h mov word ptr es:[7ch*4+2],0 mov ax,4c00h int 21h org 200h func: jmp short main table dw func0,func1 main: ;cmp ah,0 ;je func0 ;cmp ah,1 ;je func1 mov al,ah mov ah,0 mov si,ax add si,si call word ptr table[si] mov ax,4c00h int 21h func0: push bx ;扇区号 mov ax,dx mov bl,18 div bl inc ah mov Cl, AH ; track number mov AH, 0 mov BL, 80 div BL mov CH, AH ; plane number mov DH, Al ; drive letter mov DL, 0 ; reading mov AH, 2 ; the number of sectors read mov Al, . 1 POP BX int 13 is RET func1: Push BX ; sector number MOV AX, DX MOV BL, 18 is div BL inc is AH mov Cl, AH ; track number mov AH, 0 mov BL, 80 div BL mov CH, AH ; plane number mov DH, Al ; drive letter mov DL, 0 ; write mov AH, . 3 ; the number of sectors written mov Al, . 1 POP BX int 13H RET funcend: NOP code ends End Start
Course Design 2