5.2 Register

A register operand is the symbolic name of register prefixed by the percent % symbol.

Due to historical reasons, the i386 has some interesting combinations of registers. Let us start with 8-bit registers. The eight 8-bit registers are al, ah, bl, bh, cl, ch, dl, and dh. The “l” stands for “low”, and the “h” stands for “high”.

There are four general purpose 16-bit registers. Each one is a concatenation of the matching 8-bit registers. For example, ax (“x” stands for extended) is a 16-bit register in which al makes up the least significant 8 bits, and ah makes up the most signifiant 8 bits. The other three 16-bit registers are bx, cx and dx. There are other 16-bit registers, but they are generally not useful when a modern processor is in 32-bit mode.

Last, but not least, there are 8 32-bit registers. The first four general purpose registers are extensions of ax to dx. eax is the “enchanced” (hence “e”) version of ax. This means that ax is the least significant 16 bits of eax. There is no register that specifies only the most significant 16 bits of eax. Likewise, ebx, ecx andedx are enhanced versions of bx, cx and dx.

The other four 32-bit registers are useful as pointers.

The following is an example of a mov instruction that copies the value of eax to ebx:

mov %eax,%ebx