diff --git a/content/blog/x86_64_cheatsheet.md b/content/blog/x86_64_cheatsheet.md index 22f6d03..d26bae9 100644 --- a/content/blog/x86_64_cheatsheet.md +++ b/content/blog/x86_64_cheatsheet.md @@ -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| diff --git a/sass/style.scss b/sass/style.scss index 6e9f27d..6ee5710 100644 --- a/sass/style.scss +++ b/sass/style.scss @@ -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;}