code segment
assume cs:code
start:
push cs
pop ds
call waitfree
jnz err
mov dx,1f0h
add dx,3
mov al,3fh
out dx,al
call waitfree
jnz err
mov al,0
inc dx
out dx,al
call waitfree
jnz err
inc dx
out dx,al
call waitfree
jnz err
mov al,0e0h
inc dx
out dx,al
call waitfree
jnz err
mov dx,1f2h
mov al,2
out dx,al
call waitfree
jnz err
mov dx,1f7h
mov al,21h
out dx,al
call waitfree
jnz err
mov cx,256
mov dx,1f0h
mov di,offset sector
push cs
pop es
read: in ax,dx
stosw
loop read
err:
add dx,7
in al,dx
mov bx,ax
__wait: call waitfree
jnz __wait
mov cx,256
mov dx,1f0h
read1: in ax,dx
stosw
loop read1
mov ax,4c00h
int 21h
waitfree proc
push cx
push dx
push ax
Mov DX,1f7H
Sub CX,CX
_Wait: In AL,DX
and al,0d0h
Cmp AL,50H
Jz Ok
Loop _Wait
ok: pop ax
pop dx
pop cx
ret
waitfree endp
align 16
sector dw 512 dup(0)
code ends
end start