July 17, 2020
On Friday, 17 July 2020 at 21:03:46 UTC, Iain Buclaw wrote:
>
>
> On 17/07/2020 05:14, Cecil Ward via Digitalmars-d wrote:
>> [...]
>
> There's nothing magical going on in order to resolve symbolic names.  Each output, input and label operand has an index value from 0 to N, and you just need to replace "%[symbol]" with "%3".
>
> https://github.com/gcc-mirror/gcc/blob/f1b6e46c417224887c2f21baa6d4c538a25fe9fb/gcc/stmt.c#L528-L603 https://github.com/gcc-mirror/gcc/blob/f1b6e46c417224887c2f21baa6d4c538a25fe9fb/gcc/stmt.c#L605-L663
>
> This could even be done in the semantic pass of GccAsmStatement (dmd/iasmgcc.d), so no need for LDC to duplicate this locally (plus, you are in the safe land of D to do the required string manipulation).

Many thanks Iain, that’s good of you. Your work is much appreciated as always.
July 18, 2020
On Friday, 17 July 2020 at 21:36:52 UTC, Iain Buclaw wrote:n (:)

On Friday, 17 July 2020 at 21:36:52 UTC, Iain Buclaw wrote:
> You mean, like in compiler-explorer?
>
> https://explore.dgnu.org/z/LWqJdi
>
> Hover over the asm instructions to see explanations.

I’ve used this website a lot. Matt Godbolt told me he isn’t the maintainer of it. It’s excellent. I’ve used Matt’s own high level multi-language website too. I just noticed the instruction definitions for the first time the other day. I am using an ipad so I can’t hover, and I can’t remember now how I managed to be able to see an instruction definition note. (I should explain - I’m (effectively) confined to bed due to illness so I don’t use a laptop or desktop PC any more, just the iPad.)
July 19, 2020
On Saturday, 18 July 2020 at 23:10:22 UTC, Cecil Ward wrote:
> On Friday, 17 July 2020 at 21:36:52 UTC, Iain Buclaw wrote:n (:)
>
> On Friday, 17 July 2020 at 21:36:52 UTC, Iain Buclaw wrote:
>> You mean, like in compiler-explorer?
>>
>> https://explore.dgnu.org/z/LWqJdi
>>
>> Hover over the asm instructions to see explanations.
>
> I’ve used this website a lot. Matt Godbolt told me he isn’t the maintainer of it. It’s excellent. I’ve used Matt’s own high level multi-language website too. I just noticed the instruction definitions for the first time the other day. I am using an ipad so I can’t hover, and I can’t remember now how I managed to be able to see an instruction definition note. (I should explain - I’m (effectively) confined to bed due to illness so I don’t use a laptop or desktop PC any more, just the iPad.)

I’ve just worked it out : on ipad a "long-press" on a particular line of asm brings up a context menu (I presume this is what the right mouse button produces) and the good stuff is in that menu, including x6 insn definitions. Many thanks
July 19, 2020
On 19/07/2020 02:28, Cecil Ward via Digitalmars-d wrote:
> On Saturday, 18 July 2020 at 23:10:22 UTC, Cecil Ward wrote:
>> On Friday, 17 July 2020 at 21:36:52 UTC, Iain Buclaw wrote:n (:)
>>
>> On Friday, 17 July 2020 at 21:36:52 UTC, Iain Buclaw wrote:
>>> You mean, like in compiler-explorer?
>>>
>>> https://explore.dgnu.org/z/LWqJdi
>>>
>>> Hover over the asm instructions to see explanations.
>>
>> I’ve used this website a lot. Matt Godbolt told me he isn’t the maintainer of it. It’s excellent. I’ve used Matt’s own high level multi-language website too. I just noticed the instruction definitions for the first time the other day. I am using an ipad so I can’t hover, and I can’t remember now how I managed to be able to see an instruction definition note. (I should explain - I’m (effectively) confined to bed due to illness so I don’t use a laptop or desktop PC any more, just the iPad.)
> 
> I’ve just worked it out : on ipad a "long-press" on a particular line of asm brings up a context menu (I presume this is what the right mouse button produces) and the good stuff is in that menu, including x6 insn definitions. Many thanks

They pull it all from the Intel software developers manual.

https://www.felixcloutier.com/x86/

https://github.com/compiler-explorer/compiler-explorer/blob/master/etc/scripts/docenizer.py
July 19, 2020
On 19/07/2020 01:10, Cecil Ward via Digitalmars-d wrote:
> On Friday, 17 July 2020 at 21:36:52 UTC, Iain Buclaw wrote:n (:)
> 
> On Friday, 17 July 2020 at 21:36:52 UTC, Iain Buclaw wrote:
>> You mean, like in compiler-explorer?
>>
>> https://explore.dgnu.org/z/LWqJdi
>>
>> Hover over the asm instructions to see explanations.
> 
> I’ve used this website a lot. Matt Godbolt told me he isn’t the maintainer of it. It’s excellent. I’ve used Matt’s own high level multi-language website too. I just noticed the instruction definitions for the first time the other day. I am using an ipad so I can’t hover, and I can’t remember now how I managed to be able to see an instruction definition note. (I should explain - I’m (effectively) confined to bed due to illness so I don’t use a laptop or desktop PC any more, just the iPad.)

Yes, I maintain it (and build the hundreds of gdc cross compilers that are used on it :-)
October 02, 2020
On 7/14/2020 5:26 PM, Cecil Ward wrote:
> I have a fair amount of code written in D which uses GDC’s syntax for inline asm and currently it is therefore GDC-only. It would like people to be able to build it alternatively using LDC as well, and maybe even DMD.

DMD's inline assembler syntax is what is used in Intel's CPU manuals. I sometimes wonder why other compilers don't do the same. It can be a bit wacky, but it's not that much code to implement and it makes following the code along with the manuals much easier.
October 03, 2020
On Friday, 2 October 2020 at 22:01:53 UTC, Walter Bright wrote:
> On 7/14/2020 5:26 PM, Cecil Ward wrote:
>> I have a fair amount of code written in D which uses GDC’s syntax for inline asm and currently it is therefore GDC-only. It would like people to be able to build it alternatively using LDC as well, and maybe even DMD.
>
> DMD's inline assembler syntax is what is used in Intel's CPU manuals. I sometimes wonder why other compilers don't do the same. It can be a bit wacky, but it's not that much code to implement and it makes following the code along with the manuals much easier.

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.

Having studied compiler design as part of my major subjects, I say that the inline Assembly parser could build that information just as easily.
October 03, 2020
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...


October 03, 2020
On Saturday, 3 October 2020 at 08:51:58 UTC, Paulo Pinto wrote:
> On Friday, 2 October 2020 at 22:01:53 UTC, Walter Bright wrote:
>> On 7/14/2020 5:26 PM, Cecil Ward wrote:
>>> I have a fair amount of code written in D which uses GDC’s syntax for inline asm and currently it is therefore GDC-only. It would like people to be able to build it alternatively using LDC as well, and maybe even DMD.
>>
>> DMD's inline assembler syntax is what is used in Intel's CPU manuals. I sometimes wonder why other compilers don't do the same. It can be a bit wacky, but it's not that much code to implement and it makes following the code along with the manuals much easier.
>
> 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.
>
> Having studied compiler design as part of my major subjects, I say that the inline Assembly parser could build that information just as easily.

Yeah sure. See https://github.com/ldc-developers/ldc/blob/master/gen/asm-x86.h for an incomplete x86 implementation. And now imagine something like this for every ISA supported by GCC and LLVM, and keeping it up-to-date. - The whole point of the GCC/GDC-style assembly is genericity - an instructions template provided by the user as a string to be forwarded to the assembler (opaque for the optimizer), and outputs/inputs/clobbers provided separately because that's the only thing the pre-assembler stages need to know.

Considering inline asm is mostly used as a last resort for some very low-level stuff, extending the front-end by a full-blown parser for every ISA would be an absolutely improportionate effort.
October 03, 2020
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);
}