Assembly
A family of programming languages that provide instructions close to machine code.
Learn
Intro:
- https://shikaan.github.io/assembly/x86/guide/2024/09/08/x86-64-introduction-hello.html
- https://shikaan.github.io/assembly/x86/guide/2024/09/16/x86-64-conditionals.html
Notes
- In x86-64 there are 16 general-purpose registers, each 8 byte wide.
- You can access the whole register or only a part of it (1 byte, 2 bytes, 4 bytes).
ripis the instruction pointer register.- File extensions:
.s,.asm. - File sections:
.data(variables, optional),.rodata(constants, optional),.text(code, mandatory). - File syntax:
;for comments,dbto declare strings,equto declare numbers. - Declare a label with
lbl:, reference it withlbl. - Control Transfer Instruction (CTI) types: unconditional (e.g.
jmp) and conditional (e.g.je,jg,jl). eflagsis a 32-bit register that stores various flags (e.g. zero flagZF, sign flagSF).
Instructions
mov r1, r2: mover2tor1add r1, r2:r1+r2, the result will be stored inraxcmp r1, r2:r1-r2, the result will be stored inZF,SFflagsjmp lbl: gotolblje lbl: gotolblifZF=1jg lbl: gotolblifSF=0jl lbl: gotolblifSF=1syscall: make a syscall with the identifier stored inrax