关于引导加载程序的问题
我正在关注brokenthorn操作开发系列来研究bootloader。在 此页面 中,这是三行代码:
bits 16 ; We are still in 16 bit Real Mode
org 0x7c00 ; We are loaded by BIOS at 0x7C00
start: jmp loader ; jump over OEM block
在第二行中,他加载了BIOS 位于软盘 7c00 处。为什么不在 0000 上?我检查了 在软盘映像上存储引导加载程序的位置?< /a>. 这里也给出了同样的事情。但原因并没有解释。有人可以向我解释一下吗?提前致谢。
编辑:我很困惑,因为在后面的教程中的同一个站点中,代码是:
bits 16 ; we are in 16 bit real mode
org 0 ; we will set regisers later
start: jmp main ; jump to start of bootloader
然后在 main
main:
;----------------------------------------------------
; code located at 0000:7C00, adjust segment registers
;----------------------------------------------------
cli ; disable interrupts
mov ax, 0x07C0 ; setup registers to point to our segment
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
现在这里为什么他使用 org 0?那为什么他要把地址复制到所有寄存器呢? 抱歉,如果这是一个愚蠢的问题。我对汇编编程非常陌生,刚刚开始阅读有关引导加载程序的内容。
I am following the brokenthorn operating development series to study about bootloader. In this page , these are the three line of code :
bits 16 ; We are still in 16 bit Real Mode
org 0x7c00 ; We are loaded by BIOS at 0x7C00
start: jmp loader ; jump over OEM block
In second line He loaded the bios at 7c00 in floppy. why not on 0000? I checked at Where to store the bootloader on a floppy image?.
Here also the same thing has given. But the reason has not explained. Can anybody explain this to me please? Thanks in advance.
EDIT : I am getting confused because in the same site in a later tutorial the codes are :
bits 16 ; we are in 16 bit real mode
org 0 ; we will set regisers later
start: jmp main ; jump to start of bootloader
and then in main
main:
;----------------------------------------------------
; code located at 0000:7C00, adjust segment registers
;----------------------------------------------------
cli ; disable interrupts
mov ax, 0x07C0 ; setup registers to point to our segment
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
Now here why he used org 0? And then why he copied the address to all the registers?
Sorry if this is a foolish question. I am very new to assembly programming and just started to read about the bootloaders.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您可能会混淆两种不同的事物。引导加载程序位于软盘的开头(我猜这是您从其中获取 0000 的地方),但 BIOS 在运行它之前将其复制到地址 7c00 的内存中。
“org”告诉汇编器,代码在复制后将从那里运行。
I think you might be conflating two different things. The bootloader lives at the beginning of the floppy (which is I guess where you get the 0000 from), but the BIOS copies it into memory at address 7c00 before it runs it.
The 'org' tells the assembler that that's where the code is going to run from, after it's been copied.
这里说:
Here it says: