LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-11-2009, 08:25 PM   #1
darkangel29
Member
 
Registered: Nov 2004
Location: Puerto Rico
Distribution: Ubuntu 10.04
Posts: 121

Rep: Reputation: 15
How to learn assembly language?


Does anybody knows any good books or websites where I can learn assembly language? I want to learn assembly well I kind of need to for a project. The project is on Intel assembly, I'm using and AMD Turion x2 cpu if that matters. Keep in mind that I have program in C, C++, C# and Basic so i have absolutely no knowledge of assembly. Thanks!!!
 
Old 01-11-2009, 08:31 PM   #2
snowman81
Member
 
Registered: Aug 2006
Location: Michigan
Distribution: Ubuntu
Posts: 279

Rep: Reputation: 30
Try this: http://www.osdata.com/topic/language/asm/asmintro.htm
 
Old 01-12-2009, 06:26 AM   #3
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
Since you already know C, I'd suggest googling for tutorials on using in-line assembler in linux. There's a few around. Then you can start with just a few lines of assembler embedded in a C program to experiment with 'hello world' type stuff.

Seeing how the assembler interfaces to C should help you understand what is going on.

If you want to do serious programming you probably need a book - have a look at Amazon for reviews and to see what people are buying.
 
Old 01-12-2009, 08:24 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194
Quote:
Originally Posted by darkangel29 View Post
I'm using and AMD Turion x2 cpu if that matters.
Do you want to use x86 assembler or x86_64? (I haven't looked up "Turion" so I'm not certain it supports x86_64, but I expect it does).
You can (and maybe should) program in x86 assembler first, even if your OS kernel is x86_64. You can use x86_64 assembler only if your OS is x86_64.

Quote:
Keep in mind that I have program in C, C++, C# and Basic
I think the best way to use assembler is in subroutines designed with C calling conventions (which can be called easily from C++ as well). But I don't know which assembly tutorials focus on that.

Quote:
Originally Posted by snowman81 View Post
That is partially generic ASM and partially Motorola 68xxx ASM. It really wouldn't be very helpful to someone learning X86 or X86_64 asm.

Quote:
Originally Posted by maroonbaboon View Post
Since you already know C, I'd suggest googling for tutorials on using in-line assembler in linux.
1) That would be inline assembler in GCC, not "in linux". It really doesn't matter which OS you're running GCC in. I use inline assembler in GCC in Windows XP64.

2) I find the syntax for in-line assembler very convoluted (compared to ordinary assembler). It is a useful thing to know for a C or C++ programmer writing OS code or extreme performance critical code. But I wouldn't suggest it for an ASM beginner. Learning in-line assembler first would be much harder than learning how to write whole subroutines in ASM first.

Quote:
If you want to do serious programming you probably need a book - have a look at Amazon for reviews and to see what people are buying.
Sorry I didn't take the time to find a good online tutorial today, but I have seen some good ones (for x86, not x86_64). I don't see any advantage to a physical book. The type of author that knows how to get a publisher interested is usually not the type of author that knows how to explain a topic like asm programming. The physical books I have seen are worse than free online alternatives.

Last edited by johnsfine; 01-12-2009 at 08:26 AM.
 
Old 01-12-2009, 09:20 AM   #5
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
check out this site:
http://linuxasmtools.net/
 
Old 01-12-2009, 11:16 AM   #6
Four
Member
 
Registered: Aug 2005
Posts: 298

Rep: Reputation: 30
You can also write C code and generate assembly out of it ("-S" flag for gcc). I don't think you'll learn everything from doing this but; sometimes "I can do it in C; but how in assembly?" .
 
Old 01-12-2009, 11:18 AM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
Remember that assembly language is architecture-specific (greatly hinders portability) and processor-specific (but usually backwards compatible enough not to cause problems).

Either way here are some general tutorials, I'm assuming Intel assembly = x86:
http://drpaulcarter.com/pcasm/
http://asm.sourceforge.net/
http://www.freeprogrammingresources.com/assembly.html
 
Old 01-12-2009, 11:21 AM   #8
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
This question has come up frequently.

You should also take a look at Jonathan Bartlett's most excellent "Programming from the Ground Up":

http://download.savannah.gnu.org/rel...0-booksize.pdf
 
Old 01-12-2009, 12:30 PM   #9
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194
Quote:
Originally Posted by darkangel29 View Post
The project is on Intel assembly
I expect by "Intel" you mean the architecture, not the syntax. But if you meant the syntax, that must be considered when selecting a tutorial.

Nasm uses "Intel syntax" which is an assembly language syntax just for the X86 architectures.

Gas (GNU assembler) uses a generic syntax across architectures. That DOES NOT mean assembler code will be portable across architectures. It just means certain syntax rules are the same across various assembly languages for various architectures.

For X86, both Nasm and Gas are assembly languages for the same machine language, so all the semantic concepts are the same. But the syntax is seriously different. You want to pick just one to learn first. Both are available on both Windows and Linux, but for Linux there are some significant advantages to choosing Gas over Nasm. On Windows, I would probably choose Nasm (on Windows you might also choose Masm). As you see in links others have posted, there are other assemblers beyond those, but I think each one is either fairly close to Intel syntax or fairly close to GNU assembler syntax (AKA AT&T syntax).

Last edited by johnsfine; 01-12-2009 at 12:32 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
What are some good resources to learn assembly Language? theunixwizard General 16 07-24-2008 03:27 AM
Assembly Language Books JMJ_coder Programming 3 05-06-2008 04:04 PM
assembly language in linux herbertgnanaraja Programming 12 09-21-2006 03:52 AM
Assembly Language syntax ashlesha Linux - Newbie 4 06-30-2006 04:22 PM
Assembly Language, and networks grizzly Programming 5 12-11-2003 09:50 PM

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

All times are GMT -5. The time now is 11:21 AM.

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