Skip to the content ForoHackers
Log inJoin

Assembly: start here

Assembly
#541 · Ophuscado · · Report

Assembly is the human-readable form of a processor's machine instructions, one line per instruction. Each processor family has its own, so there is no single assembly language. You rarely write whole programs in it, but reading it tells you what a compiler really produced, how the hardware behaves, and what a debugger or disassembler is showing you.

Key concepts

  • Registers: a few fast storage slots inside the CPU; most instructions work on them.
  • Memory and addressing: loads and stores move data between registers and memory, with several addressing modes.
  • Instruction set: arithmetic, logic, comparison, jumps and calls; the machine's whole vocabulary.
  • The stack and calling convention: how arguments, return addresses and saved registers are passed between functions.
  • Flags and branching: comparisons set status that conditional jumps test.
  • System interface: how a program asks the operating system for services.

Vocabulary

  • Mnemonic: the short name of an instruction, such as mov or add.
  • Opcode: the number in machine code that selects the instruction.
  • ABI: application binary interface, the rules a platform sets for calls and data layout.
  • Assembler and linker: tools that turn assembly into object code and join it into a program.

What to study, in order

  1. Compile a small C function to assembly and read it line by line.
  2. Learn the registers, stack and calling convention of one architecture.
  3. Write a function in assembly and call it from C.
  4. Write a tiny program that prints text through the system interface, with no library.
  5. Step through code in a debugger, watching registers and the stack change.
  6. Read the processor vendor's instruction reference for the instructions you meet.

Related tags

#c #compilers #reverse-engineering #computer-architecture

Log in or join to reply.