Learning x64 on a Linux system

I am looking for good resources to build x64 on a Linux system to write the code myself. I am also looking for some introductory concepts such as memory spaces (stack, heap, etc.). I found a good free book online, programming from scratch, the problem is that it focuses on x32 linux systems. I also played a lot with gcc -S, however it creates some weird characters like .LAndhwateverstuff Can someone point me in the right direction? I may have been a terrible webseeker, but I could not find many resources on this.

+3
source share
6 answers

The best way to learn about the assembly is to look at the existing working assembly (the actual assembly, not the internal environment or something else) and find out how it works. And of course, ask questions to those who wrote this. Once you understand how this works, write something similar to yourself and continue to work on it until its result matches code C.

My x264 project, for example, has several tens of thousands of x64 build lines that you can view online through the gitweb interface .

+2
source

Some of the materials you need are called ABI (Application Binary Interface), which defines function conventions and system calls. You need this to write an ASM that interacts with C code or OS system calls.

Another material you want to know is a set of machine instructions and registers.

AMD has several PDF documents that describe these things for x86_64.

+1
source

I read Professional Build Language and 32 / 64bit Build 80x86 . Both of them would teach you the basics of x86 / x86-64, and one of them would at least mention how the C function call would be created and returned, so this might be useful.

But, as Zan said, you probably want to really learn about ABI if you want to write a function in an assembly and make good use of it with C.

+1
source

Here you go. LinuxAssembly

Oh, and if you need to store temporary values ​​or function arguments on the † stack, then unless you call C functions, you should put them on your own stack, not on rsp; rbp makes a good pointer to the data stack. That way, you never have to create or destroy a stack frame. Local variables should still go at the top of your return address.

PS. Auto preview of this wiki is amazing.

† What you no longer need, as you have eight additional registers to play.

+1
source

I do not know if you are familiar with the x86 (32bits) build. But if you have not done so since x86_64 in the x86 extension, you should start with x86. Any x86 build code will run the x86_64 machine since the instruction set was design compatible. x86 is quite complicated and you cannot make it interesting to use the x86_64 command if you are not ok with x86.

You don’t know anything about the collection. You just need a set of instructions and focus enough to understand what you are reading.

First read the simple C functions you wrote yourself.

+1
source

All Articles