Assembly language varies depending on the architecture (e.g., x86, ARM). Below is a generic assembly language cheat sheet, but keep in mind that specific instructions and syntax may vary based on the architecture. This example assumes x86 assembly:
Registers
- General Purpose Registers (x86):
EAX
,EBX
,ECX
,EDX
- Index Registers:
ESI
,EDI
- Base Pointer:
EBP
- Stack Pointer:
ESP
Memory Access
Load Effective Address:
lea eax, [ebx + ecx]
Move Data:
mov eax, 42
Arithmetic Operations
Addition:
add eax, ebx
Subtraction:
sub eax, edx
Multiplication:
imul eax, ebx
Division:
idiv ecx
Control Flow
Jump (Unconditional):
jmp target_label
Conditional Jump:
cmp eax, ebx
je equal_label
Procedures
Procedure Declaration:
my_procedure:
Procedure Call:
call my_procedure
Stack Operations
Push onto Stack:
push eax
Pop from Stack:
pop ebx
String Operations
Move String:
mov esi, source_address
mov edi, destination_address
mov ecx, string_length
rep movsb
Input/Output
Print to Console:
mov eax, 4 ; System call for sys_write
mov ebx, 1 ; File descriptor 1 is stdout
mov ecx, message ; Message to write
mov edx, message_len ; Length of the message
int 0x80 ; Interrupt to invoke system call
Read from Console:
mov eax, 3 ; System call for sys_read
mov ebx, 0 ; File descriptor 0 is stdin
mov ecx, buffer ; Buffer to read into
mov edx, buffer_len ; Maximum length to read
int 0x80 ; Interrupt to invoke system call
System Calls
Exit Program:
mov eax, 1 ; System call for sys_exit
xor ebx, ebx ; Exit code 0
int 0x80 ; Interrupt to invoke system call
Comments
Single-Line Comment:
; This is a single-line comment
Multi-Line Comment:
/*
* This is a
* multi-line comment
*/
This assembly language cheat sheet provides a basic overview of common instructions and concepts. Assembly language is platform-specific, so be sure to refer to the documentation for the specific architecture you are working with for more detailed information.