invented to allow machine operations to be expressed in Mnemonic abbreviations
- assembly has no standard
require assembler to convert it into machine code
어셈블리 자체가 1대1 매칭되다 보니 기계어랑 거의 차이가 없긴 한데
string인 assembly와 binary 인 assembly는 차이가 크다
Assembly Language Notion
Assembly Languages
Instructions
- Control flow transfer
- Unconditional:
call
,jmp
,ret
- direct : constant destination
- indirect: runtime chosen destination address
- Conditional:
j
<condition>eflags (x86), rflags (x86_64)
- data manipulation: arithmetic
add, sub, imul, mul, idiv, div, inc, dec
logic:and, or, xor, not
updates rflags register in x86cmp rax, rbx
,test rax, rax
- data transfer
mov, xchg, push, pop
- System calls
- Many other privileged or purpose-built instructions
Calling Conventions
Callee and caller functions must agree on argument passing (함수 간 레지스터 사용 규칙을 정해, 충돌 방지.)
Registers are shared between functions, so calling conventions should agree on what registers are protected.
- Callee-saved registers 호출된 함수가 복구해야 하는 레지스터
- Caller-saved registers 호출자가 복구해야 하는 레지스터
Syntax
Intel syntax (Microsoft Assembler, Nasm, IDA Pro)
- mnemonic destination, source
AT&T syntax (objdump, GNU Assembler)
- mnemonic source, destination