Assembly (ASM)

Assembly (ASM) is a low-level programming language that provides a human-readable, mnemonic representation of a computer's machine code instructions.

Assembly syntax depends on the architecture of the device you're programming.

  • Registers - Small, high speed storage locations within the processor that hold data and instructions temporarily during execution.
'mov    x3, x0'         ; Move/Copy TO x3 FROM x0
'mov    x2, #7'         ; Loads the register with the literal value of 7

Assembly Basics

Assembly is executed through a process known as the fetch-decode-execute cycle.

  • Fetch - The CPU retrieves an instruction from memory.
  • Decode - The CPU interprets the fetched instruction, determining what action is required and identifying the involved operands.
  • Execute - The CPU carries out the operation.

Assembly Instructions

Arithmetic

ADD R1, R2
SUB R1, R2
MUL R1, R2
DIV R1, R2

Logic

AND R1, R2
OR R1, R2
XOR R1, R2
NOT R1, R2

Control

JMP LABEL ; jump
CMP R1, R2 ; compare
JE LABEL ; jump if equal
JNE LABEL ; Jump if not equal

Data Movement

MOV R1, R2 ; move data from R1 to R2
PUSH R1
POP R1

Assembly Operands

Assembly Mnemonics