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 04-24-2012, 12:31 AM   #1
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Rep: Reputation: Disabled
A Good AMD64 Assembly Tutorial


I don't already know assembly (well I get the consepts not the code) so any syntax will be fine, although I want it to be ether Intel or At&T.
I read somewhere that 64-Bit assembly is easier than 32-Bit assembly.
I do want it to interface with C!
 
Old 04-24-2012, 03:37 AM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Strong recommendation: Programming from the Ground Up:

http://savannah.nongnu.org/projects/pgubook/

AMD64 is a superset of Intel x86. This book will absolutely get you going - satisfaction guaranteed!

IMHO...
 
1 members found this post helpful.
Old 04-24-2012, 06:42 AM   #3
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by paulsm4 View Post
Strong recommendation: Programming from the Ground Up:

http://savannah.nongnu.org/projects/pgubook/

AMD64 is a superset of Intel x86.
I took a quick look. If I understood correctly, that book focuses on

32 bit x86
AT&T syntax
Whole programs in asm

If you want to learn 64 bit asm, some reference (not tutorial) documents you really should have are:
http://support.amd.com/us/Processor_...594_APM_v3.pdf
support.amd.com/us/Embedded_TechDocs/24592.pdf
and the newest ABI from
http://www.x86-64.org/documentation/

26568 covers SSE2, which is a nice next step after the basics.

For more advanced 64 bit programming you should also find 24593. To find any of these (they move around) I do a google search for AMD and the document number.

Those AMD documents use the operand sequence of Intel syntax. AT&T has the opposite sequence. But it isn't too hard to get used to remembering the document's operand sequence is backward. Armed with that knowledge, it should be easy to look at the asm code from a compiled C function (preferably in a GUI debugger, where you can step through and see register values as they change) and look up the instructions and addressing modes in those PDFs and understand what the code does.
Once you understand how a function compiled from C acts in asm, it is easy to write your own. No tutorial needed.

The ABI document can be confusing because it gives a lot of detail in order to put precision ahead of comprehensibility. There are two simple register lists whose meaning is almost all you ever need to know from the ABI:
passed: rdi, rsi, rdx, rcx, r8, r9
preserved: rbp, rbx, r12, r13, r14, r15
When passing parameters to functions, many parameter types are reasonable to pass in registers. The first six such parameters are passed in the registers listed.
A function is free to modify most registers, so when it returns those registers must be assumed to have lost whatever useful contents they might have had. But if a function uses registers in the preserved list, it must save the value each had before and restore it before returning.
Another important fact in the ABI is that function return values that can reasonably be in a general register are in rax.

For all the cases where you can't easily tell whether a parameter or return value should go in a register, the ABI ought to tell you, but I think it only yields that knowledge to ABI guru's. The easy way to answer all obscure ABI questions is to write a simple C function that has the same ABI issue, compile it, and see what gcc did.

Last edited by johnsfine; 04-24-2012 at 07:09 AM.
 
Old 04-24-2012, 12:50 PM   #4
NyteOwl
Member
 
Registered: Aug 2008
Location: Nova Scotia, Canada
Distribution: Slackware, OpenBSD, others periodically
Posts: 512

Rep: Reputation: 139Reputation: 139
Another good basic book is "Assembly Language Step by Step: Programming with Linux" by Jeff Duntemann.
 
Old 04-28-2012, 11:26 PM   #5
Garda
Member
 
Registered: May 2005
Distribution: Debian
Posts: 83
Blog Entries: 2

Rep: Reputation: 15
I don't know if this is going to be useful, but I thought I would post the link here anyway.
 
  


Reply

Tags
amd64, assembly


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
[SOLVED] Assembly Language Tutorial konsolelover Programming 9 09-06-2011 02:30 AM
16 bit assembly good for ? exvor Programming 4 08-03-2007 02:30 PM
AMD64 Assembly Tutorial for Linux verdeboy2k Programming 0 09-11-2006 02:14 PM
AMD64 Assembly porgramming guides ??? qwijibow Programming 1 06-16-2005 07:33 AM
Good Assembly Books jinksys Programming 3 01-29-2004 04:41 AM


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