Thread overview | |||||
---|---|---|---|---|---|
|
May 20, 2014 DMD generates calls to next operation | ||||
---|---|---|---|---|
| ||||
While inspecting assembly code generated by DMD I found this weird bit of assembly: 0000000000000000 <_Dmain>: 0: 55 push rbp 1: 48 8b ec mov rbp,rsp 4: 48 83 ec 10 sub rsp,0x10 8: c7 45 f8 05 00 00 00 mov DWORD PTR [rbp-0x8],0x5 f: c7 45 f8 06 00 00 00 mov DWORD PTR [rbp-0x8],0x6 16: 48 89 ef mov rdi,rbp 19: e8 00 00 00 00 call 1e <_Dmain+0x1e> 1e: 31 c0 xor eax,eax 20: c9 leave 21: c3 ret 22: 66 0f 1f 44 00 00 nop WORD PTR [rax+rax*1+0x0] It seems to call/jump to the operation right after it. Why does it do that? Code: void main() { int x = 5; void innerFunc() { import std.stdio; writeln(x); } x = 6; innerFunc(); } Also I don't really get where it's supposed to call innerFunc. It seems it's never mentioned inside the generated main function. |
May 20, 2014 Re: DMD generates calls to next operation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | On 05/20/14 21:46, Jeroen Bollen via Digitalmars-d wrote: > While inspecting assembly code generated by DMD I found this weird bit of assembly: > 19: e8 00 00 00 00 call 1e <_Dmain+0x1e> > 1e: 31 c0 xor eax,eax > 20: c9 leave > 21: c3 ret > 22: 66 0f 1f 44 00 00 nop WORD PTR [rax+rax*1+0x0] > > It seems to call/jump to the operation right after it. Why does it do that? http://forum.dlang.org/post/mailman.427.1364814654.4724.digitalmars-d-learn@puremagic.com artur |
May 20, 2014 Re: DMD generates calls to next operation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Artur Skawina | On Tuesday, 20 May 2014 at 19:55:17 UTC, Artur Skawina via
Digitalmars-d wrote:
> On 05/20/14 21:46, Jeroen Bollen via Digitalmars-d wrote:
>> While inspecting assembly code generated by DMD I found this
>> weird bit of assembly:
>
>> 19: e8 00 00 00 00 call 1e <_Dmain+0x1e>
>> 1e: 31 c0 xor eax,eax
>> 20: c9 leave
>> 21: c3 ret
>> 22: 66 0f 1f 44 00 00 nop WORD PTR [rax+rax*1+0x0]
>>
>> It seems to call/jump to the operation right after it. Why does
>> it do that?
>
> http://forum.dlang.org/post/mailman.427.1364814654.4724.digitalmars-d-learn@puremagic.com
>
> artur
Thanks :P
|
Copyright © 1999-2021 by the D Language Foundation