Howto assembly
==============
https://www.tutorialspoint.com/assembly_programming
Sections
--------
Sections are used to structure the code
data: declaring initialized data or constants
bss: declaring variables
text: contains actual code
Comments
--------
Comments can be single lines or inline
;this is a comment
CPU-Registers
-------------
Registers=CPU-internal memory storage locations
* Genearl registers (Data, pointer, index registers)
* Control registers
* Segment registers
* 32 bit register:
eax: Accumulator
ebx: Base
ecx: Counter
edx: Data
System calls
------------
Used to instruct the kernel to do something
1. Put the system call number in the EAX register.
2. Store the arguments to the system call in the registers EBX, ECX, etc.
3. Call the relevant interrupt (80h).
4. The result is usually returned in the EAX register.
| %eax | Name | %ebx | %ecx | %edx | %esx | %edi |
|------|-----------|----------------|--------------|--------|------|------|
| 1 | sys_exit | int | - | - | - | - |
| 2 | sys_fork | struct pt_regs | - | - | - | - |
| 3 | sys_read | unsigned int | char * | size_t | - | - |
| 4 | sys_write | unsigned int | const char * | size_t | - | - |
| 5 | sys_open | const char * | int | int | - | - |
| 6 | sys_close | unsigned int | - | - | - | - |