在以下x86汇编代码中:
dd 0x1BADB002
dd 0x00
dd - (0x1BADB002+0x00)
这些值似乎不会分配给任何变量。那么这段代码做了什么呢?我听说过它存储在内存中,但到底在哪里?
答案 0 :(得分:1)
dd
是一个“伪指令”,它将4字节常量组装到输出中,就像add eax,eax
将0x01 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?