NASM 引导加载程序的奇怪行为
我正在尝试编写一个引导加载程序,但在我发现这个问题之前,我的实验都没有成功: 为什么这个引导加载程序代码不起作用?
我已经简化了这个程序,只将一个字符写入屏幕。
[ORG 0x7C00]
[BITS 16]
realstart:
jmp start
nop
start:
xor ax,ax
mov ds,ax
mov es,ax
xor bx,bx
mov ah, 0x0e
print:
mov al, "A"
int 0x10
end:
cli
hlt
times 510 - ($-$$) db 0
dw 0xAA55
它编译得很好,但在 objdump没有任何 int 0x10 命令。
如果我留下字符串(此文件)一切正常。
问题在哪里?
(在Cygwin Win7 SP1上使用NASM 2.08.02-1编译)
I'm trying to write a boot loader but none of my experiments didn’t worked until I found this question: Why doesn't this boot loader code work?
I had simplified this program to only write a char to screen.
[ORG 0x7C00]
[BITS 16]
realstart:
jmp start
nop
start:
xor ax,ax
mov ds,ax
mov es,ax
xor bx,bx
mov ah, 0x0e
print:
mov al, "A"
int 0x10
end:
cli
hlt
times 510 - ($-$) db 0
dw 0xAA55
It compiles fine, but in the objdump there isn’t any int 0x10 command.
If I leave strings (this file) it all works fine.
Where's the catch?
(Compiling with NASM 2.08.02-1 on Cygwin Win7 SP1)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
代码看起来没有什么问题。如果用 ndisasm 反汇编代码会得到缺少 int 0x10 的结果,那将是非常奇怪的。所以我猜你谈论的是在运行时转储代码。引导扇区通常在跳转指令之后包含引导记录(它告诉引导加载程序有关介质的大小等)。也许 BIOS 出于某种原因正在干预它认为的引导记录?
There seem to be nothing wrong with the code. It would be very strange if disassembling the code with ndisasm yields a result with int 0x10 missing. So I guess you talk about dumping the code in runtime. The bootsector normally contains a boot record right after the jump instruction (which tells the bootloader about the size of the media and such). Perhaps the BIOS is medling with what it thinks is a boot record for some reason?
尝试此代码。如果它不起作用,请告诉我。
Try This Code.If It Doesn't Work,make me know.