LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-15-2010, 08:43 AM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
ASM Syntax


I wonder what ASM syntax do you think is better? Here's the way I see it:

Intel Syntax
Good:
  • No cryptic, hard-to-type %s and $s everywhere.
  • Intuitive operator order (dest, source)
Bad:
  • You have to manually say the size of the data if the assembler can't figure it out
AT&T Syntax
Good:
  • Operator suffixes to explicitly say the data size you want.
Bad:
  • Cryptic-looking, difficult-to-type %s and $s everywhere
  • Confusing operator order (source, dest)
 
Old 04-15-2010, 09:57 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Personally I prefer Intel.. but that's probably just because I started out doing 16 bit asm on Windows. It's just what you get used to..
 
Old 04-15-2010, 12:06 PM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I prefer gas syntax despite learning Intel syntax and writing a lot of code in Intel syntax long before learning gas syntax.

Switching between two operand orders is confusing. Neither order is inherently more or less confusing.

I'm not thrilled with the % or many other ways that gas syntax tries to be more machine independent than an assembler can actually be.

But typed and sized memory reference operands are just so wrong for the concept of assembler programming that they overwhelm everything else.

When the assembler can't deduce the size or type of an operand from the register choice or instruction or other local info, that info should be provided as a suffix to the opcode. Anything else is just wrong. The Intel method of defining type and size info for memory addresses is a bad way of pretending that asm is a high level language. If you want to program in C, program in C. If you want to program in asm, a name defined for an address should just represent an address, not an address type and size.
 
Old 04-15-2010, 12:19 PM   #4
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Maybe someone should make a new assembly syntax, one that is like intel with automatic operand sizing.
 
Old 04-15-2010, 12:37 PM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
@johnsfine

Personally I find the destination-first syntax easier to understand, maybe because I'm used to C, and because in mov instructions, for example, I can at a glance see what the register/memory location is set to by looking at the end of the line.

Also I find typing those awkwardly-placed '%' and '$' characters so often very difficult, and with time maybe a bit painful. I also think they add a lot of "visual noise", severely reducing the code's readability.

And I find that [] is more intuitive than () for dereferencing for me, again because I am used to C. But I don't really care, this is more of a little thing.

But OTOH I really like AT&T Syntax's size suffixes. You're right that it is a little wrong for the assembler to remember the types and sizes of "variables".

@smeezekitty

Wouldn't it be great if there would be an assenbly language with instruction suffixes, destination-first operator order, and no symbols before registers/literals?

Last edited by MTK358; 04-15-2010 at 12:40 PM.
 
Old 04-15-2010, 01:40 PM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
@johnsfine

Personally I find the destination-first syntax easier to understand, maybe because I'm used to C, and because in mov instructions, for example, I can at a glance see what the register/memory location is set to by looking at the end of the line.

Also I find typing those awkwardly-placed '%' and '$' characters so often very difficult, and with time maybe a bit painful. I also think they add a lot of "visual noise", severely reducing the code's readability.

And I find that [] is more intuitive than () for dereferencing for me, again because I am used to C. But I don't really care, this is more of a little thing.

But OTOH I really like AT&T Syntax's size suffixes. You're right that it is a little wrong for the assembler to remember the types and sizes of "variables".

@smeezekitty

Wouldn't it be great if there would be an assenbly language with instruction suffixes, destination-first operator order, and no symbols before registers/literals?
Assembly syntax is a non-issue nowadays. One typically writes in assembly only reset routine and ISRs which comprise a very small part of the code present in a system.

Complaining about assembly syntax doesn't mane sense in the presence of languages like Perl/Python/etc - one can write a layer of assembly text generating subs in them and choose for the subs the desired order of operands (src, dst, whatever else).

Or just plain parser that would accept the desired assembly syntax.
 
Old 04-15-2010, 09:49 PM   #7
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
@sergei: some people write assembly for fun not because they have to
 
Old 04-16-2010, 04:46 AM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by kbp View Post
@sergei: some people write assembly for fun not because they have to
Of course; by the same token they can write for fun an assembly compiler or a preprocessor.
 
Old 04-16-2010, 06:37 AM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by kbp View Post
@sergei: some people write assembly for fun not because they have to
Exactly.

Quote:
Originally Posted by Sergei Steshenko View Post
Of course; by the same token they can write for fun an assembly compiler or a preprocessor.
I might, but I don't know how.
 
Old 04-16-2010, 07:06 AM   #10
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post

I might, but I don't know how.
You have no chance of knowing - because whenever you are supposed to make an effort and to read, comprehend and analyze, you skip.
 
Old 04-16-2010, 08:15 AM   #11
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Sergei;
Please do not post personal comments about other members in this way. Perhaps a better reply would be to ask if MTK wants to learn?

MTK;
Please consider that your reply to Sergei was inviting a retort.

Both of you----please look for opportunities to NOT bicker with each other.
 
Old 04-18-2010, 07:24 PM   #12
samjh
Member
 
Registered: Mar 2008
Location: Australia
Distribution: Mint
Posts: 33

Rep: Reputation: 15
Quote:
Originally Posted by MTK358 View Post
I wonder what ASM syntax do you think is better? Here's the way I see it:

Intel Syntax
Good:
  • Intuitive operator order (dest, source)

AT&T Syntax
...
Bad:
  • Confusing operator order (source, dest)
Hmm. I think the AT&T order (source, dest) is more intuitive. I can see where your coming from, if you treat it like an assignment operator in higher-level languages, but I don't treat it that way.
 
Old 04-18-2010, 07:38 PM   #13
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Yes, I look at it like an assignment operator. I am also used to C's memory and string functions, that take the destination first.

I also find it easier to see at a glance what the register is being assigned to when the source is at the end of the line.
 
Old 04-18-2010, 08:04 PM   #14
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by MTK358 View Post
Yes, I look at it like an assignment operator. I am also used to C's memory and string functions, that take the destination first.

I also find it easier to see at a glance what the register is being assigned to when the source is at the end of the line.
I agree.
But it would also be trivial to have automatic sizing.
Both syntax's are flawed and outdated.
 
Old 04-18-2010, 08:08 PM   #15
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Compare:

Intel:

Code:
mov eax, 2
mov ebx, [ebp+8]
AT&T:

Code:
movl $2, %eax
movl 8(%ebp), %ebx
My idea:

Code:
movl eax, 2
movl ebx, [ebp+8]
Or maybe "d" for "dword" makes more sense than "l" for "long"?

Last edited by MTK358; 04-18-2010 at 08:10 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ASM or C++? Hb_Kai Programming 16 01-20-2010 09:12 AM
[python] syntax Error : invalid syntax Python_user Programming 2 09-06-2009 12:52 PM
ASM x32 vs ASM x64 Tegramon Programming 3 02-27-2008 02:26 PM
gnu asm syntax? santana Programming 4 10-18-2007 10:25 AM
I/O in ASM Mercurius Programming 10 11-16-2006 07:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration