prnstr macro msg
mov ah, 09h
lea dx, msg
int 21h
endm
readnum macro val
mov ah, 01h
int 21h
mov ah, 00h
sub al, '0'
mov bl, 0ah
mul bl
mov bl, al
mov bh, 00h
mov ax, 0100h
int 21h
sub al, '0'
add bx, ax
mov val, bl
endm
data segment
track db ?
sector db ?
head db ?
drive db ?
msg1 db 0dh, 0ah, "Enter the track number : $"
msg2 db 0dh, 0ah, "Enter the sector number : $"
msg3 db 0dh, 0ah, "Enter the head number (0/1) : $"
msg4 db "Enter drive (0-A, 1-B, 80-C) : $"
msg5 db 0dh, 0ah, "Sector contains : $"
msg6 db 0dh, 0ah, "Failure in reading sector...$"
msg7 db 0dh, 0ah, "Reading sector...$"
buf db 512 dup(' ')
data ends
code segment
assume cs:code, ds:data, es:data
start :
mov ax, data
mov ds, ax
mov es, ax
prnstr msg4
readnum drive
prnstr msg3
readnum head
prnstr msg1
readnum track
prnstr msg2
readnum sector
prnstr msg7
mov al, 01h
mov ch, track
mov cl, sector
mov dh, head
mov dl, drive
lea bx, buf
mov ah, 02h
int 13h
jnc success
prnstr msg6
jmp stop
success :
prnstr msg5
mov cx, 512
mov ah, 02h
mov si, offset buf
next :
mov dl, [si]
int 21h
inc si
loop next
stop :
mov ax, 4c00h
int 21h
code ends
end start