From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from spam02.hesby.net (spam01.hesby.net [81.29.32.152]) by sourceware.org (Postfix) with ESMTP id 9FE7A38532D8 for ; Fri, 25 Nov 2022 13:32:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9FE7A38532D8 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hesbynett.no Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=hesbynett.no Received: from [192.168.0.63] (unknown [79.161.10.130]) by spam02.hesby.net (Halon) with ESMTPSA id 879f21bb-6cc5-11ed-8752-506b8dfa0e58; Fri, 25 Nov 2022 14:31:58 +0100 (CET) Message-ID: <72aad43c-cd02-24a9-9bdf-fd75fe76ce5a@hesbynett.no> Date: Fri, 25 Nov 2022 14:31:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Please, really, make `-masm=intel` the default for x86 Content-Language: en-GB To: LIU Hao , gcc@gcc.gnu.org References: <4b31677c-255c-2796-67c4-2d67f0c9fa60@126.com> From: David Brown In-Reply-To: <4b31677c-255c-2796-67c4-2d67f0c9fa60@126.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3490.0 required=5.0 tests=BAYES_00,BODY_8BITS,KAM_DMARC_STATUS,KAM_NUMSUBJECT,KHOP_HELO_FCRDNS,NICE_REPLY_A,SPF_HELO_NONE,TXREP,T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 25/11/2022 07:39, LIU Hao via Gcc wrote: > I am a Windows developer and I have been writing x86 and amd64 assembly > for more than ten years. One annoying thing about GCC is that, for x86 > if I need to write I piece of inline assembly then I have to do it > twice: one in AT&T syntax and one in Intel syntax. > > > The AT&T syntax is an awkward foreign dialect, designed originally for > PDP-11 and spoken by bumpkins that knew little about x86 or ARM. No > official Intel or AMD documentation ever adopts it. The syntax is > terrible. Consider: > >    movl $1, %eax  ; k; moves $1 into EAX >                   ; but in high-level languages we expect '%eax = $1', >                   ; so it goes awkwardly backwards. > > If this looks fine to you, please re-consider: > >   cmpl $1, %eax >   jg .L1          ; does this mean 'jump if $1 is greater than %eax' >                   ; or something stupidly reversed? > > If CMP still looks fine to you, please consider how to write VFMADD231PD > in AT&T syntax, really. > > > I have been tired of such inconsistency. For God's sake, please > deprecate it. > > You can have all the personal preferences or prejudices you want, but that won't change the fact that AT&T syntax was the standard x86 assembly from long before Intel thought of making their own syntax, and it is here to stay. No one is going to deprecate it, remove it, or change any defaults. #include int main(void) { int temp=0; asm ( ".intel_syntax noprefix" "mov %0, 1" ".att_syntax" : "=r"(temp) : /* no input*/ ); printf("temp=%d\n", temp); } A use feature that could be added to gcc, perhaps, would be a way to let the user specify the assembler dialect as part of the "asm" statement: asm __attribute__((masm = "intel")) ( ... ) The idea with this is that it would issue the requested ".intel_syntax noprefix" or ".att_syntax" at the start of the assembly, and the appropriate directive to return to normal syntax at the end - adjusting according to the "-masm" setting for the compilation. This would, I think, let people write the assembly once in the syntax they choose, and have it work smoothly regardless of which syntax is chosen for compilation.