NEW asm.dlang.org site

Iain Buclaw via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Jan 27 05:04:59 PST 2015


On 27 January 2015 at 12:53, ZombineDev via Digitalmars-d-announce
<digitalmars-d-announce at puremagic.com> wrote:
> Thanks for the good work! It would be really nice if in the future we could
> compare  DMD, GDC and LDC (and SDC when it becomes more usable) at
> asm.dlang.org. (Btw a nice choice of name :) )
>
> I have a couple of questions about the output when looking at a C++[1]
> program and the same in GDC[2] and DMD[3](I am not very familiar with
> assembly):
>
> 1) Syntax:
> AFAIU, (_D)main pushes 3 and 4 to the stack and calls (example.)add. Then
> (example.)add loads them from the stack in two registers and adds them.
> IIRC, dmd passes parameters in reverse order (of the normal C way) and
> that's why pushing and loading 3 and 4 from the stack is in reverse order.
>

That is correct

> However why does DMD use hex instead of decimal notation?
> [I was also a little confused about positive vs negative indexing of bp and
> the order of src and dst in the arguments to movl, but then I noticed that I
> am comparing x86 and x86_64, so I managed to answer those questions myself
> :D ]

Because GCC and GDC dumps are raw assembly.  Whereas with DMD I had to
disassemble from object code (using obbjdump).  This is an
implementation detail really of how DMD works vs GCC backend.


>
> 2) _Dmain:
> I also noticed that the output of gdc-4.4 and gdc-4.6 does not include a
> label for _Dmain (nor the regular C main). Is this a problem of the
> disassembly, or just how older version of GDC produced code?
>

GCC-Explorer thinks _Dmain is a label, and sees that it is unused (not
called from anywhere).  So it removes it.  In later versions of GDC, a
C main function is included in the compilation, and so now references
_Dmain.

I guess this is a bug in GCC Explorer itself that will need to be
addressed somehow.


Iain.


More information about the Digitalmars-d-announce mailing list