如何阅读 /解析组件?如何知道前处理器执行了哪些说明?

发布于 2025-02-04 20:56:21 字数 359 浏览 3 评论 0原文

我希望能够从上到下阅读它,但是NASM似乎具有某种类似于CPP的预处理器。

我试图理解的代码:

; Infinite loop (e9 fd ff)
loop:
    jmp loop 

; Fill with 510 zeros minus the size of the previous code
times 510-($-$$) db 0
; Magic number
dw 0xaa55

我很困惑,因为我希望该代码永远不会到达底部的底部,该部分设置了启动扇区中最后一个单词的0xaa55。我希望,当它从上到下读取文件时,当它到达循环时:JMP循环它将永远卡在那里,永远不会达到底部代码。

I would expect to be able to read it from top to bottom but it seems like nasm has some sort of pre-processor similar to the CPP.

Code I am trying to understand:

; Infinite loop (e9 fd ff)
loop:
    jmp loop 

; Fill with 510 zeros minus the size of the previous code
times 510-($-$) db 0
; Magic number
dw 0xaa55

I am confused because I would expect the code to never reach the bottom section which sets 0xaa55 at the last word in the boot sector. I would expect that as it reads the file from top to bottom, when it reaches the loop: jmp loop it would just be stuck there looping forever, it would never reach the bottom code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

や三分注定 2025-02-11 20:56:21

您的分析是正确的,您会陷入JMP循环。 CPU从未打算实际执行底部;只需要在那里才能在那里硬件 bios即可识别代码为有效的引导扇区并运行它。

Your analysis is correct, you get stuck at the jmp loop. The bottom section is never intended for the CPU to actually execute; it just needs to be there for the hardware BIOS to recognize the code as a valid boot sector and run it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文