Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>General advice:</h3> <p>It isn't just "x86 assembler". Each assembler is a bit different and they are not generally compatible with each other. I recommend the NASM assembler because it is widely used, easy to install, and supports 64bit assembly.</p> <p>Read a good book on x86 assembler to get a feel for the basics (registers, conditional jumps, arithmetic, etc). I read <em>Art of Assembly</em> by Randall Hyde when I was starting out.</p> <p><a href="http://asm.sourceforge.net" rel="noreferrer">http://asm.sourceforge.net</a> looks like it has some good tutorials that you might want to work through. But if you are assembling in 64bit mode, beware that the calling convention for C functions and syscalls is different.</p> <p>You will need the CPU reference manuals. Personally, I prefer the AMD ones. You want volumes 1 and 3 of the CPU manual. The other volumes might be of interest as well.</p> <h3>64bit specific advice</h3> <p>64bit x86 assembly is almost the same as 32bit x86 assembly, since 64bit x86 is mostly backwards compatible with 32bit. You get access to the 64bit registers and a few other features, some obscure instructions are no longer valid, and the rest is the same as 32bit.</p> <p>However, the syscall convention is <em>completely</em> different on 64bit Linux. Depending on your kernel, the 32bit syscalls may or may not be available. What's worse is that the 64bit calling convention is poorly documented. I only figured it out by examining the depths of the glibc source code.</p> <p>To save you the hassle of finding this out the hard way, The syscall numbers are in the Linux source code under <code>arch/x86/include/asm/unistd_64.h</code>. The syscall number is passed in the <code>rax</code> register. The parameters are in <code>rdi</code>, <code>rsi</code>, <code>rdx</code>, <code>r10</code>, <code>r8</code>, <code>r9</code>. The call is invoked with the <code>syscall</code> instruction. The <code>syscall</code> overwrites the <code>rcx</code> register. The return is in <code>rax</code>. (A brief example can be found <a href="//cs.lmu.edu/~ray/notes/linuxsyscalls" rel="noreferrer">here</a>.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload