X86 assembly language

From ArticleWorld


The x86 assembly language is the assembly language of the x86 family of processors. As x86 is a very popular architecture, its assembly language is very popular as well.

The x86 architecture

The x86 architecture is a little-endian, CISC architecture. However, on newer processors, the instructions themselves are translated to a number of RISC-like instructions before execution. It features 8 general-purpose registers, 6 segment registers, 1 flag register and the obligatory instruction pointer.

The eight general-purpose registers are:

  1. EAX: Accumulator register
  2. EDX: Data register
  3. ECX: Counter register
  4. EBX: Base register
  5. ESP: Stack Pointer register
  6. EBP: Stack Base Pointer register
  7. ESI: Source register
  8. EDI: Destination register

Every general-purpose register can be accessed at any time, but they also serve a particular purpose. These registers are extended, 32-byte registers, but they can also be accessed in their non-extended form.

The segment registers are:

  • SS: Stack Segment
  • CS: Code Segment
  • DS: Data Segment
  • ES: Extra Segment
  • FS: F Segment
  • GS: G Segment

There are 17 flags that signal various states.

Instructions

The x86 instruction set contains a wide number of instructions, which is arguably one of the reasons why the architecture is a popular educational architecture. Although beginners have to remember many mnemonics, they can concentrate on the actual program instead of implementing even basic operations like multiplication. Several extra instructions are available, as Intel and AMD push up new optimization, making the x86 assembly language a powerful tool for optimization.

Syntax

The is no generally unified syntax for the x86 assembly language. This is because several assemblers have appeared, some of them implementing their own higher-level macros to ease some tasks.

The most common assembler syntaxes used are the GAS syntax, the MASM syntax and the HLA syntax, although the structures promoted by FASM, NASM and YASM are quite popular (especially that of NASM).