问题描述
我正在使用 Bochs 2.4.5 编写引导扇区代码.我使用 INT 13H 从软盘读取扇区.但我发现如果要读取的扇区数 > 72,则 INT13 会失败.返回码是AH=1.下面是代码,这里是 INT13.返回码是 AH=1.
I am using Bochs 2.4.5 to write a boot sector code. I use the INT 13H to read sectors from floppy. But I found that if the sector count to read > 72, the INT13 will fail. And the return code is AH=1. Below's the code and here is the INT13. The return code is AH=1.
为什么 INT 13H 不能读取超过 72 个扇区?
Why can't the INT 13H read more than 72 sectors?
xorb %ah, %ah
xorb %dl, %dl
int $0x13 # reset the floppy
movw $0x8000, %ax
movw %ax,%es
movw $0, %bx # ES:BX is the buffer
movb $0x02, %ah
movb $73, %al # how many sectors to read. 72 is ok, but >=73 is wrong.
movb $0, %ch
movb $1, %cl
movb $0, %dh
movb $0, %dl
int $0x13
感谢您的帮助.
按照Matthew Slattery的说明,我找到了相应的代码.我在这里列出了它,以供像我一样困惑的其他人使用.完整代码位于 这里.
7220 if ((drive > 1) || (head > 1) || (sector == 0) ||
7221 (num_sectors == 0) || (num_sectors > 72)) {
7222 BX_INFO("int13_diskette: read/write/verify: parameter out of range
");
7223 SET_AH(1);
7224 set_diskette_ret_status(1);
7225 SET_AL(0); // no sectors read
7226 SET_CF(); // error occurred
7227 return;
7228 }
推荐答案
你使用的是 Bochs,所以答案可以在 Bochs BIOS 源:BIOS 正在对扇区数执行显式范围检查,如果出现则拒绝它它大于 72(或等于 0).
You're using Bochs, so the answer can be found in the Bochs BIOS source: the BIOS is performing an explicit range check on the number of sectors, and rejecting it if it is greater than 72 (or equal to 0).
这篇关于AH=2 的 BIOS INT 13H 每次只能读取 72 个扇区.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!