LinuxQuestions.org
Visit Jeremy's Blog.
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 06-27-2009, 03:25 PM   #1
Windows to Linux
Member
 
Registered: Sep 2008
Distribution: Ubuntu LTS
Posts: 57

Rep: Reputation: 16
Assembler confusion


What category of assembly would the GCC assembler fall into? I'm trying to find a book on it over the web, but I don't want to download a different program to do this. It is already installed on my new laptop (as minGW, unsure about repartitioning Vista [have seen a few odd stories about that])

Also, any book suggestions?

I have taken a brief look at Art of Assembly, but.............

Last edited by Windows to Linux; 06-27-2009 at 03:47 PM.
 
Old 06-28-2009, 01:45 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
I suspect you've got confused between two similar things in computer programming:

GCC = GNU Compiler Collection ... but it is primarily a C/C++ compiler.

AFAIK: it is not an assembler.

Last edited by Simon Bridge; 06-28-2009 at 01:49 AM.
 
Old 06-28-2009, 03:56 AM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by Simon Bridge View Post
I suspect you've got confused between two similar things in computer programming:

GCC = GNU Compiler Collection ... but it is primarily a C/C++ compiler.

AFAIK: it is not an assembler.
"man as":

Code:
NAME
       AS - the portable GNU assembler.
 
Old 06-28-2009, 03:24 PM   #4
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 76
Quote:
Originally Posted by Sergei Steshenko View Post
"man as"
The GNU assembler manual will not actually “teach” you assembly, as much as how to use gas.

It is not clear from the OP if the desire is to learn inline assembly for use in gcc. In this case, a prerequisite is to learn normal assembly, and then try inline assembly.

I assume the OP is programming on an Intel machine, in which case many books will do. If you want a free, online book that teaches ATT syntax (the syntax used by gas), you might want Programming from the Ground Up.
 
Old 06-28-2009, 07:13 PM   #5
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
technically, it is not clear from the first post if the desire is to learn assembly language programming or computer programming. The specific mention of GCC is easily interpreted to mean OP wants to learn C/C++ and just got the terms confused.
 
Old 06-30-2009, 05:34 PM   #6
aspire1
Member
 
Registered: Dec 2008
Distribution: Ubuntu
Posts: 62

Rep: Reputation: 23
I'm working my way through Wrox publishers "Professional Assembly Language by Richard Blum" which I'm finding a very good introduction for assembly language programming under linux. Gives you enough details to use GAS as well as GCC directly to compile assembly code as well as a wealth of other usual stuff like using C libraries and functions etc.
 
Old 06-30-2009, 09:36 PM   #7
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Do you mean inline assembly?
http://en.wikipedia.org/wiki/Inline_assembler

Presumably you could use GCC as an assembler by just putting all the assembly language inside asm{}. However, GCC uses GAS to do the actual assembly.

The multi function nature of modern compilers blurs the line between high and low level code.
 
Old 07-01-2009, 03:03 AM   #8
aspire1
Member
 
Registered: Dec 2008
Distribution: Ubuntu
Posts: 62

Rep: Reputation: 23
The way it says in my book to use the gcc command rather than go through "as" then linking with "ld" process is, in it's simplest term, change the entry point of the program using the .globl directive to main from the default _start label. You can then compile and link in one step using gcc command although of course "as" and "ld" are being called behind the scene. Dynamically linking a C function like printf you don't have to go through the step of passing parameters to ld as gcc will take care of it automatically. It's a very interesting and useful book.
 
Old 07-01-2009, 08:01 AM   #9
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Quote:
You can then compile and link in one step using gcc command although of course "as" and "ld" are being called behind the scene.
There we go - remember the original question asked?
Quote:
What category of assembly would the GCC assembler fall into?
I believe we have the answer.

Last edited by Simon Bridge; 07-01-2009 at 09:58 PM.
 
Old 07-01-2009, 08:18 AM   #10
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165
Actually, the gcc compiler is a compiler suite which simultaneously supports about a half-dozen languages ... including assembler. It is a very open-ended system that can support many different assembly formats.

Most of the time, assembler-language programming statements are embedded in some other high-level language, because of the "99/01 rule." The portions of code that you actually have to do in assembler are miniscule compared to the rest of it, so by making assembly code available within a program that is written in a high-level language you can very easily do this.

Personally, I almost never use assembly code directly, although quite a few of the low-level routines in any library ... such as, say, strlen() ... are implemented that way. One of the troubles with good assembler code is that it is highly machine-specific. Another is that the code you write by hand will probably be considerably less efficient than the code which a good compiler (like gcc...) would write for you. Machine architectures really are designed for machine-generated code, and compilers include directives which allow architecture-specific code sequences to be produced. So, while I think that it's useful to have a basic understanding of machine architectures, imho "programming bareback" really isn't that useful a skill in most situations.
 
Old 07-01-2009, 08:59 AM   #11
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by sundialsvcs View Post
Actually, the gcc compiler is a compiler suite which simultaneously supports about a half-dozen languages ... including assembler.
...
Well, yes and no.

"No" in the sense "as" comes with 'binutils', not with 'gcc'.
 
Old 07-01-2009, 09:12 AM   #12
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Quote:
Originally Posted by sundialsvcs View Post
Actually, the gcc compiler is a compiler suite which simultaneously supports about a half-dozen languages ... including assembler. It is a very open-ended system that can support many different assembly formats.
As referenced in post #2 - though it probably withstands an explicit airing here too.

Quote:
Personally, I almost never use assembly code directly, although quite a few of the low-level routines in any library
OTOH: I learned programming in binary - directly. Assembly was the next step.

It used to be common for a programmer to progress from a teaching language like pascal, on to assembly (pdp11 or vax in my day). Huge swaths of code would be written in assembly.

Quote:
One of the troubles with good assembler code is that it is highly machine-specific.
Can also be an advantage, you get to take advantage of special characteristics of the machine. However, machine-neutral code is usually more useful.

Quote:
Another is that the code you write by hand will probably be considerably less efficient than the code which a good compiler (like gcc...) would write for you.
Not always - hello is usually much more efficient hand-written than compiled from hello.c

The main advantage of high level code, and principle to free software, is that it is easy for someone else to modify. (Barring deliberate obfustication.)

In the old days, we would discover that we would usually do better hand-compiling than the compilers. We also lived in a shoebox in the motorway, ate a handful of cold gravel for breakfast, worked at mill 25 hours and paid mill owner for privaledge. And when we got home, our father would cut us in two with bread knife.

See:
http://www.pbm.com/~lindahl/mel.html

But I don't expect you to believe any of that.
 
Old 07-01-2009, 12:21 PM   #13
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 76
Quote:
Originally Posted by Simon Bridge View Post
There you go - remember the original question you asked?I believe you have your answer.
I don’t think that aspire1 has asked any questions (at least in this thread)…
 
Old 07-01-2009, 09:59 PM   #14
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Quote:
Originally Posted by osor View Post
I don’t think that aspire1 has asked any questions (at least in this thread)…
Excuse me Aspire1 - that post has been corrected.


<checking>
We have not heard back from OP.
WindowstoLinux: how are you getting on?

Last edited by Simon Bridge; 07-01-2009 at 10:03 PM.
 
Old 07-02-2009, 02:23 PM   #15
Windows to Linux
Member
 
Registered: Sep 2008
Distribution: Ubuntu LTS
Posts: 57

Original Poster
Rep: Reputation: 16
Thanks, this helps

PS. All of the PC's in the house run an intel CPU, Pentium or Core2Duo, except for a netbook (not mine)

Last edited by Windows to Linux; 07-02-2009 at 02:46 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Assembler samjkd General 7 03-14-2005 01:52 PM
Assembler Firari Programming 9 12-10-2004 02:26 PM
assembler usr Programming 2 11-15-2003 05:15 PM
assembler tda Programming 4 08-21-2002 02:54 AM
Need an Assembler ChimpFace9000 Programming 1 07-18-2001 09:36 PM

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

All times are GMT -5. The time now is 09:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration