[BITS 16] 和 [ORG 0x0000] 指令的顺序
我正在开始尝试编写内核并享受其中的乐趣。我已经完成了基本的引导加载程序和以下指令:
[BITS 16]
[ORG 0x0000]
但是,在内核教程中,它以:
[ORG 0x0000]
[BITS 16]
我想知道这些指令的给出顺序是否有所不同?我使用的是 NASM 版本 2.06rc2,OpenSUSE 11.2
I am beginning some experimentation in writing a kernel and having fun doing it. I have the basic boot-loader done and the following directives:
[BITS 16]
[ORG 0x0000]
In the kernel tutorial, however, it starts with:
[ORG 0x0000]
[BITS 16]
I was wondering if the order in which these directives are given makes a difference? I am using NASM version 2.06rc2, OpenSUSE 11.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最新的 NASM 版本为 2.08,根据 NASM 上的文档判断/www.nasm.us/doc/nasmdoc6.html#section-6.1" rel="nofollow noreferrer">BITS 指令..
该顺序不应产生影响,因为它们告诉 NASM 在某些条件下生成文件,例如使用 16 位并从零开始寻址。由此看来,NASM 似乎足够聪明,知道它会生成什么样的输出。
The latest NASM is at version 2.08, and judging by the documentation on the BITS directive..
The order should not make a difference since they tell NASM to generate a file with certain conditions, such as using 16 bits and addressing start at zero. From it, NASM seems to be smart enough to know what kind of output it will generate.
哪个先出现并不重要,但我通常在程序中遵循以下顺序:(
因为
bits 16
是 NASM 的 bin 输出格式的默认值,所以我通常不会明确指定它,除非有是文件的一些bits 32
部分。)顺便说一句,带括号的形式是这些指令的较低级别的非“用户”形式。 https://www.nasm.us/xdoc/ 2.14.02/html/nasmdoc6.html#section-6.1
It doesn't matter which one comes first, but I generally follow this order in my programs:
(Because
bits 16
is the default for NASM's bin output format I generally do not specify it explicitly, except when there are somebits 32
parts to a file.)By the way, the forms with brackets are the lower-level, non-"user" forms of these directives. https://www.nasm.us/xdoc/2.14.02/html/nasmdoc6.html#section-6.1