x86 ASM:DD被用作"指令"?

时间:2017-10-01 14:33:48

标签: x86 kernel nasm osdev multiboot

在以下x86汇编代码中:

dd 0x1BADB002
dd 0x00
dd - (0x1BADB002+0x00)

这些值似乎不会分配给任何变量。那么这段代码做了什么呢?我听说过它存储在内存中,但到底在哪里?

1 个答案:

答案 0 :(得分:1)

dd是一个“伪指令”,它将4字节常量组装到输出中,就像add eax,eax0x01 0xc0汇编到输出中一样。

NASM手册section 3.2 Pseudo-Instructions描述了db / dw / dd等等。

在这种情况下,正如@MichaelPetch指出的那样,这些特定的常量用于将多引导头组合到输出文件中。 https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#OS-image-format

How does this assembly bootloader code work?

相关:

How are dw and dd different from db directives for strings?

What is the use of .byte assembler directive in gnu assembly?

x86 assembly - Which variable size to use (db, dw, dd)