This commit is contained in:
Edgar 2023-11-30 11:13:11 +01:00
parent f7c1ca40d3
commit e400e975f5
No known key found for this signature in database
GPG key ID: 70ADAE8F35904387
2 changed files with 51 additions and 0 deletions

View file

@ -9,9 +9,38 @@ categories = ["asm", "nasm", "x86_64"]
Here is a post I will probably update as I learn more x86_64 assembly.
# AMD64 ABI Reference
From left to right, pass as many parameters as will fit in registers. The order in which registers are allocated, are:
- For non-floats: rdi, rsi, rdx, rcx, r8, r9.
- For floating-point: xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7.
- Callee saved: rsp, rbx, rbp, r12-r15
- Return value: `rax`
- Stack pointer: `rsp`
- Base pointer: `rbp`
# Call Frame
Stack grows downwards.
```asm
caller:
push rbp ; save old frame
mov rbp, rsp ; init frame
; arguments passed in the stack are upwards
mov r14, [rbp + 0x10]
; ...
mov rsp, rbp
pop rbp
ret
```
## x86_64 Cheatsheet
|s|b|
|---|---|
|a|b|
|a|b|
|a|b|
|a|b|

View file

@ -209,3 +209,25 @@ h1,h2,h3 {
border-bottom: 4px $color solid;
border-bottom-color: #FFAA00;
}
table {
width: 100%;
margin: 1em 0px;
border-collapse: collapse;
}
table, th, td {
border: 1px solid;
}
th {
background-color: #2c2c2c;
color: white;
}
th, td {
padding: 10px;
text-align: left;
}
tr:nth-child(even) {background-color: #1b2127;}