Resources for Learning x86_64 Assembly - 2016-06-05I guess this will be a post of mine that will actually be useful for something...
So lately, if you've seen my Github you can see that I've been learning some x86 assembly, specifically x86-64 (you know, because I run a 64-bit version of the Linux kernel). But I found that there aren't many people interested in x86-64 (which isn't saying much considering I'm talking about Assembly, much less x86-64 Assembly), but I was able to find some information, get some help, and a nice digital book that teaches you x86 Assembly (not x86-64, please keep that in mind).
The first of the resources is the book, which a friend of mine, @ComradeKeys suggested to me, called Programming from the Ground Up by Jonathan Bartlett. This book will teach you a lot of the basics of the Assembly language and how to work with it, but it's only written for x86 32-bit. However, that doesn't mean that it's hard to port to x86-64, in fact if you look at my Github you'll see that I've been porting some of the examples to x86-64 using the new registers and word sizes (I've worked on getting some of the new x86-64 ABI in there but that's taking its time since I'm still new to Assembly in general). So you should be able to use that link for help.
Of course, something else that I noticed had changed were system calls. The first thing I should point out is that instead of doing the `int $0x80' you instead use the `syscall' command to call the Linux kernel. But you'll also notice thhat the registers to use aren't the same and that the call numbers aren't the same (yeah, 1 is no longer exit, but write), so I had to look this up and found this link which gives a very nice and complete list of system calls, most of which you will most likely never use. This link also answers the question of which registers to use as parameters for the system calls, just look at the top of the table provided (%rax, %rdi, %rsi, etc.). With this you should have a pretty good idea of what's going on.
However, one problem that I came up with was when I tried using the stack, which is why I would like to point something out that is very important, remember that x86-64 uses quads which are 8 bytes instead of 4 like longs are (this means instead of using `movl' you use `movq'). I say this because I had this issue when porting one of the examples from the digital book mentioned earlier and I had to ask a question on StackOverflow about it that can be found here.
Of course, then there's the ABI, which you can pay attention to or not if it's just a small project, but it's a good idea to learn it. For this I have a couple links, one is the actual x86-64 ABI from the x86-64 website (yeah, I know right, these people have a website?) and another much smaller version which is a University of Chicago x86-64 Instructions and ABI handout. Both are nice resources, just that one is a lot shorter than the other.
With this you have some nice resources to start out with, and I'm pretty sure there are more, but this is what I have to offer you. I hope this post is helpful.