当前位置: 代码迷 >> 汇编语言 >> 怎么使用端口读写磁盘
  详细解决方案

怎么使用端口读写磁盘

热度:6177   发布时间:2013-02-26 00:00:00.0
如何使用端口读写磁盘
不用BIOS或DOS中断,如何使用端口来读写磁盘?磁盘寻址用LBA模式。

------解决方案--------------------------------------------------------

commmandbad dw 01f0h
res:
mov dx,commandbad
add dx,07h
in al,dx
test al,80h
jnz res ;check if or not busy

mov dx,commandbad
add dx,02h
mov al,00h
out dx,al
mov al,1h
out dx,al ;set sector count

mov dx,commandbad
add dx,03h
mov al,00h
out dx,al
mov al,00h
out dx,al ;set LBA low

mov dx,commandbad
add dx,04h
mov al,00h
out dx,al
out dx,al ;set LBA mid

mov dx,commandbad
add dx,05h
mov al,00h
out dx,al
out dx,al ;set LBA high

mov dx,commandbad
add dx,06h
mov al,40h
out dx,al ;set LBA enable

mov dx,commandbad
add dx,07h
mov al,24h
out dx,al ;set 24h command

@@:
in al,dx
test al,80h
jnz @b ;check if or not busy

test al,01h
jnz res ;check if or not error


test al,40h 
jz res ;check DRAY is or not ready 

mov di,0h
@@:
mov dx,commandbad
insw ;read data to result
mov dx,commandbad
add dx,07h
IN AL,DX
test AL, 08h
jnz @b

這個是我以前寫的 你參考下看看
  相关解决方案