免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3976 | 回复: 2
打印 上一主题 下一主题

用汇编直接对硬盘操作的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-05-07 13:21 |只看该作者 |倒序浏览
我想写个操作系统,我需要对硬盘进行直接操作,INT13我用过,现在的问题是我不想调用中断,而想直接用I/O指令,或MOV指令,写I/O端口来操作硬盘,有谁写过这种程序么,也就是INT13的内部程序。

论坛徽章:
0
2 [报告]
发表于 2010-05-07 23:11 |只看该作者
我猜这要看硬盘或者硬盘控制器本身的手册了。估计英文的比较好找。

论坛徽章:
0
3 [报告]
发表于 2010-05-08 18:31 |只看该作者
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP