;*** reads track 10, sector10, side 0, saves data to a file
;*** uses int 13h to read the sector, int 21h, file services to write the file

Title   diskrw13.ASM
Page    60,132

stk     segment stack                ; set up a stack
        dw      64 dup(?)
stk     ends

data    segment
buf     db      512 dup(?)
fn      db      'A:\test.dat',0    ; file name
fh      dw      ?                    ;file handle
data    ends

code    segment
        assume  ds:data, cs:code
main    proc    far                  
        mov     ax,data         ; Bookkeeping...
        mov     ds,ax
        mov     es,ax
        
        mov     cx,0a0ah        ; track 10, sector 10
        mov     al,1            ; 1 sector
        mov     ah,2            ; read sector command
        mov     dh,0            ; side 0
        mov     dl,0            ; drive A
        mov     bx,offset buf   ; address of read buffer
        int     13h             ; read it

        mov     ah,3ch            ;create file...
        mov     cx,0              ;normal file       
        mov     dx,offset fn
        int     21h
        mov     fh,ax             ;store file handle 
        mov     ah,40h            ;write file
        mov     bx,fh
        mov     cx,12
        mov     dx,offset buf
        int     21h

        mov     ah,3eh            ;close file
        mov     bx,fh
        int     21h

        mov     ax,4c00h                          ; Return to DOS
        int     21h
main    endp         
code    ends
        end     main