【问题标题】:Assembly INT 13h - read disk problem汇编 INT 13h - 读取磁盘问题
【发布时间】:2010-12-31 16:01:52
【问题描述】:

我需要能够编写一个汇编程序来读取磁盘的第一个扇区(MBR)并将其写入软盘或至少显示数据。 我知道 INT 13h 和 25h 在 Windows 保护模式下不起作用,我什至在 Dos 中尝试了我的代码,但是当我运行程序时 dos 系统挂起。这是代码:

  MOV byte ptr es:[bx], offset result
  MOV     AL,1 ;number ofsectors to read
  MOV     Cl,1 
  MOV     ch,0  
  mov     dl,80h  ;the HDD
  mov     dh,1
  mov ah,02h
  INT     13h

result 是缓冲区变量。

提前致谢。

【问题讨论】:

  • 请使用“代码”功能标记代码以进行演示。

标签: assembly dos disk


【解决方案1】:

我认为这条线是错误的

MOV byte ptr es:[bx], offset result ' attempts to write memory [bx]

应该是

MOV es, segment_offset ' probably not needed
MOV bx, buffer_offset
...

也许你还得恢复ES,例子

push es
mov  es, ...
...
pop  es
' done

【讨论】:

  • 感谢 Nick D 我将代码更改为: mov dx,80h ;first physical disk mov cx,1 ;head 1, sector 0 mov bx,ds ; mov es,bx ;指向引导记录缓冲区 mov bx,OFFSET result ;读入引导记录 mov ax,0201h ;读取一个扇区 int 13h 看来可以了。当我打印出来时它给了我很多垃圾但是我如何确保它是真正的 MBR?感谢大家耐心阅读我的问题。
  • @Auxiliary,查看mirror.href.com/thestarman/asm/mbr/STDMBR.htm,它提供了很多关于 MBR 的信息。
【解决方案2】:

是的。它终于奏效了。这是代码(仅在 DOS 中运行,因为 INT 13h 不能在 Windows 操作系统中运行。

            mov dx,80h
        mov cx,1
        mov bx,ds
        mov es,bx
        mov bx,offset result
        mov ax,0201h
        int 13h     

【讨论】:

    猜你喜欢
    • 2013-01-09
    • 2013-02-01
    • 2013-11-20
    • 2014-07-23
    • 2017-08-10
    • 2013-11-02
    • 1970-01-01
    • 2021-12-20
    • 2020-02-22
    相关资源
    最近更新 更多