notes/school/os-sec/20181015_1-x86.md
Valentin Brandl c2f877c1ac
All checks were successful
the build was successful
Add OSSec notes
2018-10-15 15:54:54 +02:00

89 lines
1.5 KiB
Markdown

---
title: x86 ASM
date: 2018-10-15
---
# x86 ASM
## Outline
* 32 bit System
## Syntax
### Intel Syntax (verwendet in Vorlesung)
* Intel Syntax (Ziel Operant ist immer links)
* Adressen in `[1234]`
### AT&T Syntax
* Ziel Operant ist rechts
* Register mit `%`
* Number Literals mit `$`
## Memory Layout
* `.bss` global uninitialized variables
* `.data` global initialized variables
* heap: dynamic variables
* `.text`: code (usually read-only)
* stack: lokale Variablen + procedure activation records
* heap grows up
* stack grows down
### Stack Frame
* **ESP**: Ende des Stacks
* **EBP**: Begin des aktuellen Stack Frames
Enthält:
* Lokale Variablen
* Parameter
* Caller Adresse
| :---: |
| <prev frame> |
| --- |
| Parameters |
| :---: |
| Return address |
| :---: |
| prev frame address (alter *EBP*) |
| :---: |
| *EBP* -> |
| :---: |
| Local variables |
| :---: |
| *ESP* -> |
| :---: |
| <free memory> |
| :---: |
### MOV
* `mov eax, ebx`: `eax = ebx`
* `mov edx, [1234]`: `edx = *1234`
### `PUSH`
* `push ecx`: Wert von `ecx` auf den Stack, `esp - 4`
* `pop esi`: `esp + 4`
### `RET`
* `pop eip`
### Subroutinen
`f(1,2,3)` ->
```
push 3
push 2
push 1
call f
```