Here is a very small source file in D:
void main()
{
}
Run Code Online (Sandbox Code Playgroud)
and here objdump's disassembly of the .o file:
Disassembly of section .text._Dmain:
0000000000000000 <_Dmain>:
void main()
0: 55 push %rbp
1: 48 8b ec mov %rsp,%rbp
4: 31 c0 xor %eax,%eax
{
6: 5d pop %rbp
7: c3 retq
Run Code Online (Sandbox Code Playgroud)
The compiler is DMD64 D Compiler v2.056 running on an x86_64 Linux machine.
What I wonder is why only 32-bit EAX is being cleared rather than the whole 64-bit RAX? I assume this is a return value, required just as in a C program even if not acknowledged in D source.
Jen*_*ger 16
xor %eax,%eax
Run Code Online (Sandbox Code Playgroud)
rax在x64中清除整个内容.对双字大小寄存器的操作会自动清除完整寄存器的高位字.