views:

3123

answers:

10

I'm looking to teach myself basic hardware architecture; specifically, I'd like to learn x86 assembly for Linux or OSX. What books does this community recommend?

+7  A: 

For learning assembly language, this reference online is about as good as you can get:

The Art Of Assembly http://webster.cs.ucr.edu/AoA/index.html

JeremiahClark
Ross Rogers
Ross Rogers
+5  A: 

x86 Assembly - Wikibooks

I've found this website to be very useful, especially for explaining individual instructions.

Redbaron
+9  A: 

I learn from references, rather than tutorials; if you're the same way, you're likely to enjoy these:

Intel's documents have very good coverage of both 32-bit and 64-bit programming. I haven't looked at AMD's materials in enough depth to talk about its treatment of 32-bit programming. Nevertheless, I believe that 64-bit programming knowledge is good to have in your toolkit, so it probably helps if you get both sets of documents to look at. :-)

Chris Jester-Young
+3  A: 

If your ultimate goal is to learn hardware architecture, it might be worthwhile to work through Hennessy and Patterson's classic. (http://www.amazon.com/Computer-Architecture-Quantitative-Approach-Kaufmann/dp/1558605967). This doesn't have much information about x86 though; but will give you a solid understanding of the design issues in modern processor architecture.

Also, a good book on the linux kernel (I use http://www.amazon.com/Linux-Kernel-Primer-Architectures-Development/dp/0131181637) might useful to understand some of the more esoteric issues - task switching, page tables and the like. The book has a lot of code samples that use x86 assembly.

Pramod
+4  A: 

A note - gcc uses AT&T syntax for inline assembly. This is different from Intel syntax which is what you'll find in most references and books on the subject. I believe that you can supply Intel syntax to gcc using the right flag, but I'm not sure what that is.

Also, in regards to: "I'd like to learn x86 assembly for Linux or OSX"

Assembly language is not OS-specific (it's architecture-specific). Linux is very much a cross-platform operating system, and that means there are several different sorts of assembly language to be found in the kernel!

Of course there are things you need to know about the Linux kernel in order to program for it, but the language you're using to do it is really the same as for OSX or any other operating system.

I think the 386 manual is great general reference for x86 because it's written in a style that's both informative and easy to read.

Artelius
+2  A: 

It isn't for writing modern x86 code, but Abrash's Graphics Programming Black Book is nice to read. :)

waynecolvin
404! It's available in PDF here: http://www.gamedev.net/reference/articles/article1698.asp or from Amazon here: http://www.amazon.com/Michael-Abrashs-Graphics-Programming-Special/dp/1576101746/
Noah Medling
A: 

Here is another nice little tutorial resource that can be found here: link text

It explains in not too many words, the nuts and bolts of assembly and writing Apps from yet another different perspective. you can never get too much reading done is what I say so in addition to the other great resources, this is one to add to your bookmarks.

Steve Obbayi
+2  A: 

You can read the book by P. Carter. It is available here:

http://www.drpaulcarter.com/pcasm/

Francesco
A: 

You are actually looking for a book on x86 that also teaches you ASM.

What caen be better than Barry B. Brey's excellent book "The Intel Microprocessors 8086/8088, 80186/80188, 80286, 80386, 80486, Pentium, and Pentium Pro Processor Architecture, Programmining"

I found a link at link text

PoorLuzer
Don't worry about Linux or OSX as far as syntax is concerned. Once you have a good understanding, syntax is easy.
PoorLuzer
+3  A: 

I can thoroughly recommend Assembly Language Step By Step, for Linux! by Jeff Duntemann (I mean the most recent edition).

It is not a thin book, but it is written in very accessible language and also very enjoyable. In fact, I've liked Jeff's language very much and looking forward to read other his books.

The complex matter of hardware architecture and assembly programming is laid out with perfect balance amount of details - it is minimum which is necessary to understand how it works and to not to leave room for misinterpretation at the same time.

What is also important, the book is self-contained and comprehensive lecture about assembly, so, in my opinion, it is possible to buy only this one, spend a few (rather more) weekends reading it and experimenting with examples, and learn what is written there and all this without buying any more books or materials, as for the beginning.

I completely support what's said in the overview of this book:

The idea behind the book, nutty as it might seem, is to teach assembly language as your first programming language. No previous programming experience required.

It really implements this idea and it does it very well and leaves reader with solid foundations to jump in to advanced topics of the assembly.

It's good to know how it works, but don't be surprised if you go years without ever needing it. --Jeff Duntemann

mloskot