【发布时间】:2011-05-07 08:02:51
【问题描述】:
我正在关注brokenthorn operating development series 学习引导加载程序。在this page 中,这些是三行代码:
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
在第二行中,他在软盘中加载了 7c00 处的 bios。为什么不在 0000 上?我检查了Where to store the bootloader on a floppy image?。 这里也给出了同样的事情。但原因还没有解释。有人可以向我解释一下吗?提前致谢。
编辑:我很困惑,因为在稍后教程的同一站点中,代码是:
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?那么他为什么将地址复制到所有寄存器中? 对不起,如果这是一个愚蠢的问题。我对汇编编程非常陌生,刚刚开始阅读有关引导加载程序的信息。
【问题讨论】:
标签: assembly x86 bootloader floppy