Open main menu

CDOT Wiki β

Changes

X86 64 Register and Instruction Quick Start

299 bytes added, 09:41, 18 February 2022
Registers
[[Category:Assembly Language]]
This page contains very basic information on the x86_64 architecture: the [[Register|register]] layout and naming and the some basic instructions.
== Registers ==
Usage during [[Syscalls|syscall]]/function call:
* First six arguments are in rdi, rsi, rdx, rcx, r8d, r9d; remaining arguments are on the stack.
* For syscalls, the syscall number is in rax. For procedure calls, rax should be set to 0.
* Return value is in rax.
* The called routine is expected to preserve rsp,rbp, rbx, r12, r13, r14, and r15 but may trample any other registers.
add %r10,%r11 // add r10 and r11, put result in r11
add $5,%r10 // add 5 to r10, put result in r10 call ''label'' // call a subroutine / function / procedure
cmp %r10,%r11 // compare register r10 with register r11. The comparison sets flags in the processor status register which affect conditional jumps.
cmp $99,%r11 // compare the number 99 with register r11. The comparison sets flags in the processor status register which affect conditional jumps.
push %r10 // push r10 onto the stack
pop %r10 // pop r10 off the stack
ret // routine from subroutine (counterpart to call)
syscall // invoke a syscall (in 32-bit mode, use "int $0x80" instead)
* CPU Instruction Set and Software Developer Manuals
** AMD: httphttps://developer.amd.com/resources/documentation-articles/developer-guides-manuals/(see the AMD64 Architecture section, particularly the ''AMD64 Architecture Programmer’s Manual Volume 3: General Purpose and System Instructions'')
** Intel: http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html
* Web sites