【发布时间】:2014-12-21 19:01:19
【问题描述】:
我正在开发一个小型操作系统引导加载程序。我正在使用 int 0x13 函数来读取硬盘驱动器的第一个扇区。问题是,如果我将地址 0x7e00 作为缓冲区传递,我会得到从 0x7d71 开始的数据。
出于测试目的,硬盘驱动器大小为 2 KB,其中填充了字母“A”。我正在使用 Qemu 来测试我的引导加载程序。
这是我的一段代码:
mov ax, 0x7e00 ; Address to place data.
shr ax, 4 ; Shift right for es index instead of bx
mov es, ax ; Put buffer address into es
xor bx, bx ; Zero out bx, because it is not needed
mov ah, 0x02 ; Sub function to read disks
mov al, 0x01 ; Read 1 sector
xor ch, ch ; At cylinder 0
mov cl, 0x01 ; At sector 1
xor dh, dh ; At head 0
mov dl, 0x80 ; On hard drive 0
int 0x13
后来,当我碰巧读到 0x7d71:
mov al, byte [0x7d71] ; Get the character at 0x7d71
mov ah, 0x0e ; Sub function to teletype print al
xor bx, bx ; On page 0
mov cx, 0x00001 ; 1 time
int 0x10
我收到字母“A”。而且我可以继续在地址上上升,仍然得到一个“A”。
我是否在缓冲区中向 es:bx 发送错误? bios有问题吗? (我使用 Qemu 进行模拟,使用 nasm 进行组装,使用 magiciso 来生成 iso)
【问题讨论】:
-
只是为了澄清,您是否没有在
0x7E00获得一个扇区长度的所需数据AAAA...?INT 0x13指令执行后,AX寄存器的值是多少?
标签: assembly buffer bootloader