Inter-compiler portability of asm between gdc and ldc2 (and dmd)

Iain Buclaw ibuclaw at gdcproject.org
Sat Oct 3 22:17:57 UTC 2020


On Saturday, 3 October 2020 at 14:21:25 UTC, Paulo Pinto wrote:
> On Saturday, 3 October 2020 at 09:52:56 UTC, Ola Fosheim 
> Grøstad wrote:
>> On Saturday, 3 October 2020 at 08:51:58 UTC, Paulo Pinto wrote:
>>> It is also what I favour, the excuse those other compilers 
>>> vendor give is that the clunky syntax they use is easier to 
>>> integrate with the compiler backend for the optimiser's 
>>> understanding of what is going on.
>>
>> Huh? How come?
>>
>> I think the only reason for this is that AT&T engineers had a 
>> preference for PDP11 syntax which they were used to and that 
>> it therefore became the default syntax on Unix and thus become 
>> associated with C compilers...
>
> The PC / Amiga way of
>
> void myfunc (int data)
> {
>    asm {
>      mov bx, data
>      int 21h
>    }
> }
>
> Versus the clunky way of
>
> void myfunc (int data)
> {
>    asm("weird Assembly pseudo syntax", data);
> }

This is comparing apples and oranges.  The second example of 
myfunc() is just a glorified printf() statement, the contents of 
the string is sent to the assembler along with the rest of the 
assembly code.  That style of asm does not fit the model in dmd, 
as you don't have the ability of outputting assembly code, the 
assembler step is skipped and instead it goes straight to object 
file.


More information about the Digitalmars-d mailing list