OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:49 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Thu Aug 27, 2015 3:25 pm 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
Octocontrabass: thanks, all good points.

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Thu Aug 27, 2015 4:08 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Quote:
For the $ prefix, you have to specify which specific flavor of Intel syntax you're comparing against.
That's a good enough reason for me to avoid Intel syntax.


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Thu Aug 27, 2015 4:13 pm 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
iansjack wrote:
Quote:
For the $ prefix, you have to specify which specific flavour of Intel syntax you're comparing against.
That's a good enough reason for me to avoid Intel syntax.


This is actually the first time I've ever heard of $ for memory operands (Intel syntax), and I've started programming in x86 assembly in the 8086 days.

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Fri Aug 28, 2015 2:22 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
iansjack wrote:
That's a good enough reason for me to avoid Intel syntax.

I don't see your point. Care to elaborate?

kiznit wrote:
This is actually the first time I've ever heard of $ for memory operands (Intel syntax), and I've started programming in x86 assembly in the 8086 days.

Hmm? Maybe my post was unclear; I was trying to draw a comparison between the $ prefix in AT&T syntax with square brackets in NASM syntax.

In AT&T syntax, a $ prefix is used to differentiate immediate operands from memory operands.
In NASM syntax, square brackets are used to differentiate memory operands from immediate operands.

Both are equally good at differentiating memory and immediate operands, so it's unfair to say that the $ prefix in AT&T syntax is an advantage over NASM syntax.

Some other Intel-syntax assemblers allow symbols to be translated into memory operands, which is ridiculous. Comparing against these, AT&T syntax is obviously superior.


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Fri Aug 28, 2015 2:56 am 
Offline
Member
Member

Joined: Tue Dec 13, 2011 4:11 pm
Posts: 103
kiznit wrote:
iansjack wrote:
Quote:
For the $ prefix, you have to specify which specific flavour of Intel syntax you're comparing against.
That's a good enough reason for me to avoid Intel syntax.


This is actually the first time I've ever heard of $ for memory operands (Intel syntax), and I've started programming in x86 assembly in the 8086 days.


Code:
mov some_label, %rax

Actually moves the data pointed to by some_label to %rax, while:

Code:
mov $some_label, %rax


Moves the address of the label into %rax. Come on, AT&T, use your stupid parentheses if you want the contents at an address.
But nothing beats the syntax of those parenthesis:
Code:
mov 12(%rsi, %rcx, 4), %rax


How's THAT for readability?
(And where did the $ before the 12 and 4 constant disappear to?)


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Fri Aug 28, 2015 4:03 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Octocontrabass wrote:
iansjack wrote:
That's a good enough reason for me to avoid Intel syntax.

I don't see your point. Care to elaborate?
You answered it for me. :)
Quote:
Some other Intel-syntax assemblers allow symbols to be translated into memory operands, which is ridiculous. Comparing against these, AT&T syntax is obviously superior.

This is really a pretty silly thread. Neither syntax is braindead (although programmers who can't get to grips with one or the other of them might rightly be considered so). There are no rights or wrongs here; it's a simple matter of notation. Use whichever suits you, but let's not start religious wars about which is best.


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Fri Aug 28, 2015 5:54 am 
Offline
Member
Member

Joined: Tue Dec 13, 2011 4:11 pm
Posts: 103
iansjack wrote:
Octocontrabass wrote:
iansjack wrote:
That's a good enough reason for me to avoid Intel syntax.

I don't see your point. Care to elaborate?
You answered it for me. :)
Quote:
Some other Intel-syntax assemblers allow symbols to be translated into memory operands, which is ridiculous. Comparing against these, AT&T syntax is obviously superior.

This is really a pretty silly thread. Neither syntax is braindead (although programmers who can't get to grips with one or the other of them might rightly be considered so). There are no rights or wrongs here; it's a simple matter of notation. Use whichever suits you, but let's not start religious wars about which is best.


I never wanted to start a religious war, I just needed a rant. To be honest, my actual issue wasn't the syntax, but rather getting used to the new syntax, and the terrible error message about operand sizes, which was pretty much a lie.


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Fri Aug 28, 2015 9:25 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
I'd say that it's your assembler that's braindead. Gnu assembler, on my Mac, gives the error "test.s:1:20: error: invalid operand for instruction" for that instruction. Precise and 100% correct.


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Fri Aug 28, 2015 10:44 am 
Offline
Member
Member

Joined: Tue Dec 13, 2011 4:11 pm
Posts: 103
iansjack wrote:
I'd say that it's your assembler that's braindead. Gnu assembler, on my Mac, gives the error "test.s:1:20: error: invalid operand for instruction" for that instruction. Precise and 100% correct.


Agreed that my assembler is braindead... But it's also Gnu assembler, on my Mac...
Code:
$ /usr/local/cross/bin/x86_64-elf-as --version
GNU assembler (GNU Binutils) 2.24
Copyright 2013 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-elf'.


And it outputs:
Code:
lib/core/Start.s: Assembler messages:
lib/core/Start.s:6: Error: operand size mismatch for `test'


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Fri Aug 28, 2015 11:26 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Interesting: I get the same error message on FreeBSD as my Mac, but the same as yours on Fedora. Clearly the fault lies with the assembler (after all, error messages are not part of the syntax) so perhaps you should change the title of the thread. It would be interesting to know what error message it gives for the same error using Intel syntax, but I don't have time to test it right now.


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Fri Aug 28, 2015 11:28 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1110
Location: Tartu, Estonia
Actually I get the same strange error:
Code:
x86_64-pc-elf-as --version
GNU assembler (GNU Binutils) 2.25
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-elf'.

AT&T:
Code:
echo 'testq 0x18(%rsp), $3' | x86_64-pc-elf-as
{standard input}: Assembler messages:
{standard input}:1: Error: operand size mismatch for `test'

Intel:
Code:
cat | x86_64-pc-elf-as
.intel_syntax noprefix
test 3, qword ptr [rsp+0x18]
{standard input}: Assembler messages:
{standard input}:2: Error: operand size mismatch for `test'

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Fri Aug 28, 2015 11:53 am 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
Perhaps a bug report to the developers would be in order?

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: Braindead AT&T Syntax
PostPosted: Fri Aug 28, 2015 12:54 pm 
Offline
Member
Member

Joined: Tue Dec 13, 2011 4:11 pm
Posts: 103
iansjack wrote:
Interesting: I get the same error message on FreeBSD as my Mac, but the same as yours on Fedora. Clearly the fault lies with the assembler (after all, error messages are not part of the syntax) so perhaps you should change the title of the thread. It would be interesting to know what error message it gives for the same error using Intel syntax, but I don't have time to test it right now.

Yeah, it's an issue with the assembler, but I decided to rant about the AT&T syntax, because I'm so used to Intel syntax I automatically coded it with the operands swapped. Anyways, I changed the title.

And I've also filed a bug report...

Thanks for reproducing this, guys!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group