From 7790d370b6d9ff6e22a36e461716a39c746c551d Mon Sep 17 00:00:00 2001 From: Marcello Lamonaca Date: Fri, 17 May 2024 15:17:55 +0200 Subject: [PATCH] assembly: specify assembly variant in note name --- .../assembly/{assembly.md => intel.md} | 24 +++++++++---------- mkdocs.yml | 5 ++-- 2 files changed, 14 insertions(+), 15 deletions(-) rename docs/languages/assembly/{assembly.md => intel.md} (90%) diff --git a/docs/languages/assembly/assembly.md b/docs/languages/assembly/intel.md similarity index 90% rename from docs/languages/assembly/assembly.md rename to docs/languages/assembly/intel.md index 80e5b17..bff7302 100644 --- a/docs/languages/assembly/assembly.md +++ b/docs/languages/assembly/intel.md @@ -1,10 +1,8 @@ -# Assembly (Inter - x86_64) - -> **WARN**: Since assembly is _not_ portable all instructions will only work under a 64bit Linux system. +# Assembly (Intel) ## Compiling & Linking -```sh linenums="1" +```sh # compiling nasm -g -f elf64 src.asm # -g adds debug info, -f specifies the 64bit ELF format @@ -25,7 +23,7 @@ Every program in ELF has several sections: - `bss`: space reserved at program startup - `text`: CPU instructions -```asm linenums="1" +```asm ; export the '_start' symbol for linking global _start @@ -47,9 +45,9 @@ Declaration instructions: - `equ`: set a name to the value of an expression > **Note**: See the NASM manual, section 3.2.1 for the full list. -> **Note**: all byte declaarations are [Little Endian](https://en.wikipedia.org/wiki/Endianness "Endiannes") +> **Note**: all byte declarations are [Little Endian](https://en.wikipedia.org/wiki/Endianness "Endiannes") -```asm linenums="1" +```asm arr: db 0x12,0x34,0x56,0x78,0x90 ``` @@ -85,14 +83,14 @@ For registers `rax` through `rdx`, it's possible to access: Instructions are operations that the CPU knowns how to execute directly. They are separated from their operands by whitespace, and the operands are separated from other with commas. -```asm linenums="1" +```asm , , ..., ; Intel syntax dictates the first operand is the destination, and the second is the source DEST, SOURCE ``` -```asm linenums="1" +```asm mov eax, 0x12345678 ; copies 4 bytes to eax inc rdi ; INC: increment dec rsi ; DEC: decrement @@ -102,7 +100,7 @@ dec rsi ; DEC: decrement Adds the two operands and stores the result in the _destination_. -```asm linenums="1" +```asm add rdi, rbx ; Equivalent to rdi += rbx ``` @@ -110,7 +108,7 @@ add rdi, rbx ; Equivalent to rdi += rbx Subtract the two operands and stores the result in the _destination_. -```asm linenums="1" +```asm sub rsi, rbx ; Equivalent to rsi -= rbx ``` @@ -130,7 +128,7 @@ The **quotient** is a _64-bit_ value stored in `rax`, and the **remainder** is a ### `and`, `or`, `xor` -```asm linenums="1" +```asm and rdi, rsi ; bitwise AND or rdi, rsi ; bitwise OR xor rdi, rsi ; bitwise XOR @@ -138,7 +136,7 @@ xor rdi, rsi ; bitwise XOR ### `shr`, `shl` -```asm linenums="1" +```asm shr rsi, 2 ; right (logical) bitshift: equivalent to rsi >> 2 shl rsi, 3 ; left (logical) bitshift: equivalent to rsi << 3 ``` diff --git a/mkdocs.yml b/mkdocs.yml index 279e759..c45f0e1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -86,13 +86,14 @@ nav: - SQL: databases/sql.md - MongoDB: databases/mongo-db.md - Languages: - - Assembly: languages/assembly/assembly.md - HTML: languages/html/html.md - Markdown: languages/markdown.md - CSS: languages/css/css.md - C: languages/c/c.md - Kotlin: languages/kotlin/kotlin.md - Swift: languages/swift/swift.md + - Assembly: + - Intel: languages/assembly/intel.md - Python: - Python: languages/python/python.md - Modules: @@ -186,4 +187,4 @@ nav: - GraphQL: misc/graph-ql.md - RegEx: misc/regular-expressions.md - SSH: misc/ssh.md - - WebComponents: misc/web-components.md \ No newline at end of file + - WebComponents: misc/web-components.md