x86 ASM: DD Being Used as an “Instruction”?

非 Y 不嫁゛ 提交于 2019-12-24 07:49:43

问题


In the following x86 assembly code:

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

The values don't seem to be assigned to any variables. So what does this snippet of code do? I've heard something about it being stored in memory, but where exactly?


回答1:


dd is a "pseudo-instruction" that assembles 4-byte constants into the output, the same way that add eax,eax assembles 0x01 0xc0 into the output.

The NASM manual section 3.2 Pseudo-Instructions describes db/dw/dd and so on.

In this case, as @MichaelPetch points out, those specific constants are used to assemble a multiboot header into the output file. https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#OS-image-format

How does this assembly bootloader code work?


Related:

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)



来源:https://stackoverflow.com/questions/46513413/x86-asm-dd-being-used-as-an-instruction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!