w1coding.comAll tutorials

Assembly Syntax

Assembly lessons
  1. Environment Setup
  2. Introduction
  3. Syntax
  4. Datamovement
  5. Operators
  6. Control
  7. Loops
  8. Interupts
  9. Functions
  10. Memory
  11. System
  12. Debugging
  13. Macros
  14. Execution
  15. Floating
  16. Interupts
  17. Optimization
  18. Linking
  19. Inline
  20. Registers
  21. Bootloader
  22. Macros
  23. Stack
  24. Call
  25. Technique
  26. Responsive

Assembly Language Syntax

Assembly syntax varies slightly depending on the assembler. Two commonly used assembly syntaxes are:

  • Intel Syntax: Used in x86 and x86-64 architecture. Operands are written in destination, source order.
  • AT&T Syntax: Often used in Unix-like environments. Operands are written in source, destination order.

Intel Syntax Example

mov eax, 10     ; Move 10 into register eax
add eax, 5      ; Add 5 to eax
    

AT&T Syntax Example

movl $10, %eax  ; Move 10 into register eax
addl $5, %eax   ; Add 5 to eax
    

Registers

Registers are small storage units in the CPU. Common x86-64 registers include:

  • rax: General-purpose register (accumulator).
  • rbx: Base register.
  • rcx: Counter register.
  • rdx: Data register.