关于引导加载程序的问题

发布于 2024-10-01 04:57:40 字数 1366 浏览 2 评论 0原文

我正在关注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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

↘人皮目录ツ 2024-10-08 04:57:40

我认为您可能会混淆两种不同的事物。引导加载程序位于软盘的开头(我猜这是您从其中获取 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.

独﹏钓一江月 2024-10-08 04:57:40

这里说:

BIOS开发团队决定0x7C00
因为:

  1. 他们希望为操作系统的加载留出尽可能多的空间
    本身在 32KiB 以内。
  2. 8086/8088 使用 0x0 - 0x3FF 作为中断向量和 BIOS 数据区域
    是在追赶它。
  3. 引导扇区为512字节,引导程序的堆栈/数据区域
    需要更多 512 字节。
  4. 因此,选择了 0x7C00,即 32KiB 中的最后 1024B。

Here it says:

BIOS developer team decided 0x7C00
because:

  1. They wanted to leave as much room as possible for the OS to load
    itself within the 32KiB.
  2. 8086/8088 used 0x0 - 0x3FF for interrupts vector, and BIOS data area
    was after it.
  3. The boot sector was 512 bytes, and stack/data area for boot program
    needed more 512 bytes.
  4. So, 0x7C00, the last 1024B of 32KiB was chosen.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文