assembly: specify assembly variant in note name

This commit is contained in:
Marcello 2024-05-17 15:17:55 +02:00
parent 5e871d0787
commit 7790d370b6
Signed by: m-lamonaca
SSH key fingerprint: SHA256:8db8uii6Gweq7TbKixFBioW2T8CbgtyFETyYL3cr3zk
2 changed files with 14 additions and 15 deletions

View file

@ -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
<instr> <operand1>, <operand2>, ..., <operand_n>
; Intel syntax dictates the first operand is the destination, and the second is the source
<instr> 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
```

View file

@ -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: