如何阅读 /解析组件?如何知道前处理器执行了哪些说明?
我希望能够从上到下阅读它,但是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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的分析是正确的,您会陷入
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 thehardwareBIOS to recognize the code as a valid boot sector and run it.