无法读取汇编语言的磁盘扇区 [英] Cannot read disk sectors in assembly language

查看:135
本文介绍了无法读取汇编语言的磁盘扇区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读通过以下code盘行业:

I am trying to read disk sectors by the following code:

disk_load :
push dx 

mov ah , 0x02 ; BIOS read sector function
mov al , dh ; Read DH sectors(dh is initialized before calling the routine)
mov ch , 0x01 ;
mov dh , 0x00 ; Select head 0
mov cl , 0x02 ; Start reading from second sector ( i.e.
; after the boot sector )

mov dl,0x80 (tried with 0x00 as well)

int 0x13 ; BIOS interrupt

pop dx ; Restore DX from the stack
jc cset

cmp dh,al ; if AL ( sectors read ) != DH ( sectors expected )
jne disk_error ; 

问题是,进位标志位表示每一个错误的时间。起初我想,当我检查AL寄存器事后发现,正在读取扇区无引导盘为0x00。然后,我改变为0x80,现在AL寄存器将不得不要求部门的确切数字,但仍进位标志被设置!

Problem is ,Carry flag is set every time denoting an error. Initially I tried boot disk 0x00 which when I checked AL register afterwards found out that no sectors are being read. Then I changed to 0x80 ,now AL register would have the exact number of sectors requested but still Carry flag is being set!

那么,什么可能是这里的问题?进似乎INT 0x13后,总是设置!
我运行在虚拟框ISO文件如果该事项。

So what could be the problem here? Carry seems to be set always after int 0x13! I am running an iso file in Virtual Box if that matters.

推荐答案

一些提示:


  1. 您应该加载 CH 零,而不是一个,beause缸从零开始编号。

  2. 当失败的错误code在 AH 回来了,你看了吗?

  3. 如果您启用了软盘模拟从CD(如你所说ISO)引导复杂的事情,尤其是检查。或者只是使用虚拟软盘,直到你得到正确的事情。

  4. 的BIOS通常传入 DL 所以应该没有必要覆盖。
  5. 为你引导驱动器
  1. You should load CH with zero, not one, beause cylinders are numbered from zero.
  2. Upon failure an error code is returned in AH, have you looked at that?
  3. Booting from cd (iso as you say) complicates things, in particular check if you have floppy emulation enabled. Or just use a virtual floppy until you get things right.
  4. The BIOS usually passes the boot drive for you in DL so there should be no need to overwrite that.

使用软盘映像和固定点#1,它为我的Bochs和QEMU(没有VirtualBox的)。

Using floppy image and fixing point #1, it works for me with bochs and qemu (don't have virtualbox).

这篇关于无法读取汇编语言的磁盘扇区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆