Add README.md
This commit is contained in:
commit
9e18e86267
47
README.md
Normal file
47
README.md
Normal file
@ -0,0 +1,47 @@
|
||||
# AMD64 NASM Cheatsheet
|
||||
|
||||
## Sizes
|
||||
| Size (bits) | Size (bytes) | Name | NASM Mnemonics / Directives |
|
||||
|-------------|--------------|--------|----------------------------------------|
|
||||
| 8 | 1 | byte | DB, RESB |
|
||||
| 16 | 2 | word | DW, RESW |
|
||||
| 32 | 4 | dword | DD, RESD |
|
||||
| 64 | 8 | qword | DQ, RESQ |
|
||||
| 80 | 10 | tword | DT, REST |
|
||||
| 128 | 16 | oword | DO, RESO, DDQ, RESDQ |
|
||||
| 256 | 32 | yword | DY, RESY |
|
||||
| 512 | 64 | zword | DZ, RESZ |
|
||||
|
||||
## Registers
|
||||
|
||||
| Register | Usage | Preserved Across Function Calls |
|
||||
|------------------|-------------------------------------------------------------------------------------------|-------------------------------|
|
||||
| %rax | Temporary register; with variable arguments passes information about the number of vector registers used; 1st return register | No |
|
||||
| %rbx | Callee-saved register; optionally used as base pointer | Yes |
|
||||
| %rcx | Used to pass 4th integer argument to functions | No |
|
||||
| %rdx | Used to pass 3rd argument to functions; 2nd return register | No |
|
||||
| %rsp | Stack pointer | Yes |
|
||||
| %rbp | Callee-saved register; optionally used as frame pointer | Yes |
|
||||
| %rsi | Used to pass 2nd argument to functions | No |
|
||||
| %rdi | Used to pass 1st argument to functions | No |
|
||||
| %r8 | Used to pass 5th argument to functions | No |
|
||||
| %r9 | Used to pass 6th argument to functions | No |
|
||||
| %r10 | Temporary register, used for passing a function’s static chain pointer | No |
|
||||
| %r11 | Temporary register | No |
|
||||
| %r12–%r15 | Callee-saved registers | Yes |
|
||||
| %xmm0–%xmm1 | Used to pass and return floating point arguments | No |
|
||||
| %xmm2–%xmm7 | Used to pass floating point arguments | No |
|
||||
| %xmm8–%xmm15 | Temporary registers | No |
|
||||
| %mmx0–%mmx7 | Temporary registers | No |
|
||||
| %st0, %st1 | Temporary registers; used to return long double arguments | No |
|
||||
| %st2–%st7 | Temporary registers | No |
|
||||
| %fs | Reserved for system (as thread specific data register) | No |
|
||||
| mxcsr | SSE2 control and status word | Partial |
|
||||
| x87 SW | x87 status word | No |
|
||||
| x87 CW | x87 control word | Yes |
|
||||
|
||||
|
||||
### additional resources
|
||||
[Linux syscalls](https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/)
|
||||
[System V AMD64 ABI](https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf)
|
||||
[Getting arguments](https://github.com/tonyOreglia/argument-counter/wiki/x86-64-Linux-Assembly-Part-1:-Printing-Command-Line-Arguments)
|
Loading…
x
Reference in New Issue
Block a user