Simply wondering if anyone has any recommendations for an assembly book that goes into some of the finer details of assembly, explaining it thoroughly. It would also be nice if the book had exercises to re-enforce learning, and some sort of comparison of how typical C++ transforms into Assembly.
Recommend: Assembly Book
Members - Reputation: 708
Posted 28 February 2013 - 03:31 AM
I am not aware of any good x86 assembler book (which doesn't mean there isn't one, of course! ), but I'd like to recommend Alex Darby's "Low Level Curriculum" blog as a good explanation of how compilers generate assembly from C and C++:
The link actually references the 10th (and latest, as of February, 2013) installment of the blog, but that's the only place I know of where links to all the previous posts are. You should of course start with part 1!
Hope that was helpful to you!
Members - Reputation: 622
Posted 28 February 2013 - 08:44 AM
x86 assembly is notoriously difficult. This is because the architecture is really sloppy. I don't know of any good books besides The Art of Assembly Programming and that does not even really teach assembly it teaches HLA which was created by the author to make learning assembly easier but in reality it teaches you nothing.
I am currently in the process of learning assembly simply because it really can make you a better programmer in the long run understanding the chip architectures. Decidedly I did not start with X86. Instead I decided to go the embedded route with Micro Controllers. This allows me to start with a simple architecture with a small instruction set 49 instructions on my PIC16 and 75 instructions I think on my PIC18. They also have streamlined buses and memory architectures making it easier to understand compaired to the mess of x86 buses and hundreds of instructions. I think if you want to get into assembly you should start here with the RISC processors. Even if you don't want to go as small as an 8 bit micro you would still be better off starting with something like a 32 bit RISC arm chip. You can get a setup to run against rather easily for maybe $100. Get the board and chip to make a cheap ARM PC and install a arm version of linux.
If you want to see what I am working on check out my Dev Journal.
Really don't start with x86 start with RISC and work your way up and you will be much happier later on.
Members - Reputation: 708
Posted 28 February 2013 - 10:09 AM
Ah, yes the PIC! Very easy to learn, while these Microcontrollers are actually quite powerful (as in "being suitable for a broad range of applications", not as in a "number crunching" sort of way)! You should be able to pick up a dev board with tools and documentation for around 50$.
If you'd rather go for an ARM, get yourself one of those flashy, new Raspberry Pi devices! A single board computer for 40$? Not easy to beat, and these things are so cool to play with!
Sorry for still not giving you a suitable book to read. I learned x86 assembler with a rather old, german book "Das Assembler-Buch" by Trutz Eyke Podschun, and I'm not aware of an english translation. I'm even not sure if I can recommend it, since it was in fact difficult to read: it relied heavily on reading and understanding the numerous code examples. Besides, as blewisjr already stated, the x86 is notoriously complicated...
Edited by sgt_barnes, 28 February 2013 - 10:13 AM.
Members - Reputation: 133
Posted 28 February 2013 - 11:50 AM
I went through an online mips course a while ago, there is an emulator program that runs on pc which makes it makes it really simple to try out your programs. It's at http://chortle.ccsu.edu/assemblytutorial/index.html, it just took a while to load.
Anyway, as far as how C++ goes into assembly, it's really not any different per se than how C goes into assembly, as most of the features could be implemented as a preprocessor for C (which is how it got started i believe) though implementing exceptions via longjumps would not be pretty. And I think after most assembler tutorials you'd probably be of the opinion that the hardest part of a C compiler to write would be the parser, since C syntax is a bit icky and context dependant in some places, and C++ syntax is much more complicated than that.
The x86 instruction set is available from intel http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html.
Also, the actual code produced by a specific compiler doesn't always look like the code that would be produced by a straight forward compiler, optimization is something that is entirely compiler dependent. Knowing how a particular compiler generates assembly is the type of knowledge that could get you into some trouble if you write code that relies on it, but I know gcc at least has a switch for outputting the assembler code from C++, "-S" (case sensitive).
GDNet+ - Reputation: 10625
Posted 28 February 2013 - 05:21 PM
I agree with what the others have said about x86 assembly being more difficult than it might be worth -- but if you actually are partial to x86 assembly for whatever reason, Randall Hyde's books are quite good.
- The Art of Assembly Language
- Write Great Code, Vol. 1: Understanding the Machine
- Write Great Code, Vol. 2: Thinking Low-Level, Writing High-Level
The latter two are probably even quite good from a perspective of understanding computer architecture and how high-level code becomes assembly in general, although he does still use x86 assembly to illustrate, IIRC. They're very illustrative books, but I don't recall if there were exercises or not.
All available in Kindle or dead-tree format.
throw table_exception("(ノ ゜Д゜)ノ ︵ ┻━┻");
Members - Reputation: 834
Posted 28 February 2013 - 10:06 PM
Those are pretty good suggestions Ravyne, I was thinking of them too. I am however not sure if they have any exercises. I should probably clarify that I already understand a large amount of x86, so beginning with a smaller instruction set, might not be entirely ideal at this point. I am looking for something more complete is all.