chore: update README
This commit is contained in:
parent
3705bdd8b3
commit
2fab257d1f
1 changed files with 38 additions and 33 deletions
71
README.md
71
README.md
|
|
@ -47,18 +47,18 @@ All computation happens inside registers - RAM just holds the data until it’s
|
|||
|
||||
#### General-purpose registers
|
||||
|
||||
| 64-bit | 32-bit | 16-bit | 8-bit high | 8-bit low | Conventional use |
|
||||
|--------|--------|--------|------------|-----------|-----------------|
|
||||
| `rax` | `eax` | `ax` | `ah` | `al` | Return value, accumulator |
|
||||
| `rbx` | `ebx` | `bx` | `bh` | `bl` | Callee-saved |
|
||||
| `rcx` | `ecx` | `cx` | `ch` | `cl` | 4th argument |
|
||||
| `rdx` | `edx` | `dx` | `dh` | `dl` | 3rd argument |
|
||||
| `rsi` | `esi` | `si` | - | `sil` | 2nd argument |
|
||||
| `rdi` | `edi` | `di` | - | `dil` | 1st argument |
|
||||
| `r8` | `r8d` | `r8w` | - | `r8b` | 5th argument |
|
||||
| `r9` | `r9d` | `r9w` | - | `r9b` | 6th argument |
|
||||
| `r10`–`r11` | `r10d`–`r11d` | `r10w`–`r11w` | - | `r10b`–`r11b` | Caller-saved (scratch) |
|
||||
| `r12`–`r15` | `r12d`–`r15d` | `r12w`–`r15w` | - | `r12b`–`r15b` | Callee-saved |
|
||||
| 64-bit | 32-bit | 16-bit | 8-bit high | 8-bit low | Category | Conventional use |
|
||||
|--------|--------|--------|------------|-----------|----------|-----------------|
|
||||
| `rax` | `eax` | `ax` | `ah` | `al` | Caller-saved | Return value, accumulator |
|
||||
| `rbx` | `ebx` | `bx` | `bh` | `bl` | Callee-saved | General purpose |
|
||||
| `rcx` | `ecx` | `cx` | `ch` | `cl` | Caller-saved | 4th argument |
|
||||
| `rdx` | `edx` | `dx` | `dh` | `dl` | Caller-saved | 3rd argument |
|
||||
| `rsi` | `esi` | `si` | - | `sil` | Caller-saved | 2nd argument |
|
||||
| `rdi` | `edi` | `di` | - | `dil` | Caller-saved | 1st argument |
|
||||
| `r8` | `r8d` | `r8w` | - | `r8b` | Caller-saved | 5th argument |
|
||||
| `r9` | `r9d` | `r9w` | - | `r9b` | Caller-saved | 6th argument |
|
||||
| `r10`–`r11` | `r10d`–`r11d` | `r10w`–`r11w` | - | `r10b`–`r11b` | Caller-saved | Scratch |
|
||||
| `r12`–`r15` | `r12d`–`r15d` | `r12w`–`r15w` | - | `r12b`–`r15b` | Callee-saved | General purpose |
|
||||
|
||||
> Writing to a 32-bit register (e.g. `eax`) zeroes the upper 32 bits of its 64-bit counterpart (`rax`).
|
||||
> Writing to a 16-bit or 8-bit register leaves the upper bits unchanged.
|
||||
|
|
@ -76,27 +76,32 @@ All computation happens inside registers - RAM just holds the data until it’s
|
|||
|
||||
#### Branching
|
||||
|
||||
| Instruction | Description |
|
||||
|-------------|-------------|
|
||||
| `cmp a, b` | Compare a and b (sets flags, no result stored) |
|
||||
| `test a, b` | Bitwise AND to set flags (no result stored) |
|
||||
| `jmp label` | Unconditional jump |
|
||||
| `je label` | Jump if equal (ZF=1) |
|
||||
| `jne label` | Jump if not equal (ZF=0) |
|
||||
| `jz label` | Jump if zero (ZF=1) |
|
||||
| `jnz label` | Jump if not zero (ZF=0) |
|
||||
| `jo label` | Jump if overflow (OF=1) |
|
||||
| `jno label` | Jump if no overflow (OF=0) |
|
||||
| `js label` | Jump if sign / negative (SF=1) |
|
||||
| `jns label` | Jump if no sign / positive (SF=0) |
|
||||
| `jg label` | Jump if greater (signed) |
|
||||
| `jge label` | Jump if greater or equal (signed) |
|
||||
| `jl label` | Jump if less (signed) |
|
||||
| `jle label` | Jump if less or equal (signed) |
|
||||
| `ja label` | Jump if above (unsigned) |
|
||||
| `jae label` | Jump if above or equal (unsigned) |
|
||||
| `jb label` | Jump if below (unsigned) |
|
||||
| `jbe label` | Jump if below or equal (unsigned) |
|
||||
##### Flag-setting
|
||||
|
||||
| Instruction | Flags set | Description |
|
||||
|-------------|-----------|-------------|
|
||||
| `cmp a, b` | ZF, SF, OF, CF | Computes `a − b`, discards result |
|
||||
| `test a, b` | ZF, SF, PF | Computes `a AND b`, discards result |
|
||||
|
||||
##### Conditional jumps
|
||||
|
||||
| Instruction | Flags | Condition | Description |
|
||||
|-------------|-------|-----------|-------------|
|
||||
| `jmp` | - | always | Unconditional jump |
|
||||
| `je` / `jz` | ZF | ZF = 1 | Equal / Zero |
|
||||
| `jne` / `jnz` | ZF | ZF = 0 | Not equal / Not zero |
|
||||
| `jo` | OF | OF = 1 | Overflow |
|
||||
| `jno` | OF | OF = 0 | No overflow |
|
||||
| `js` | SF | SF = 1 | Sign (negative) |
|
||||
| `jns` | SF | SF = 0 | No sign (positive) |
|
||||
| `jg` | ZF, SF, OF | ZF=0 ∧ SF=OF | Greater (signed) |
|
||||
| `jge` | SF, OF | SF = OF | Greater or equal (signed) |
|
||||
| `jl` | SF, OF | SF ≠ OF | Less (signed) |
|
||||
| `jle` | ZF, SF, OF | ZF=1 ∨ SF≠OF | Less or equal (signed) |
|
||||
| `ja` | CF, ZF | CF=0 ∧ ZF=0 | Above (unsigned) |
|
||||
| `jae` | CF | CF = 0 | Above or equal (unsigned) |
|
||||
| `jb` | CF | CF = 1 | Below (unsigned) |
|
||||
| `jbe` | CF, ZF | CF=1 ∨ ZF=1 | Below or equal (unsigned) |
|
||||
|
||||
#### Arithmetic
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue