The 8086 processor has seven general-purpose registers for data storage, data manipulation and indirect addressing. Four registers: AX, BX, CX and DX can be accessed in two 8-bit halves. The lower half has the “L” letter, and the upper half has the “H” letter in the register name instead of “X”. General-purpose registers are presented in Fig 1.
They have some special functions, as listed below.
Some registers have special purposes.
These registers are presented in Fig 2.
Every processor has a register containing bits used to inform the software about the state of the ALU, about the result of the last arithmetic or logic operation, and used to control the behaviour of the CPU. In x86, it is called the Flags register, and is shown in fig 3.
The meaning of informational flags is as follows:
Control flags allow modification of the processor's behaviour:
The 8086, being a 16-bit processor, can address memory in real mode only (please refer to section “Segmented addressing in real mode”). It has four segment registers:
Segment registers are shown in Fig 4.
Starting from the 80386 processor general-purpose registers, stack pointer, instruction pointer, and flags register were extended to 32 bits. Inter added an extra 16 bits to each of them, leaving the possibility to access the lower half as in previous models. For example, an accumulator can be accessed as 32-bit EAX, 16-bit AX, and 8-bit AH and AL. The resulting register set is shown in Fig 5.
Similarly, the IP and flags registers were extended to 32-bit size (fig.6). Additional bits in the Eflags register are mainly used for handling the virtual memory mechanism and memory protection. They are used mainly by the operating system software, so we will not focus on details here.
In 32-bit machines, two additional segment registers were added: FS and GS (fig.7). It is worth noticing that all segment registers are still 16 bits long, but there are hidden parts, not available directly to the programmer, used for storage of descriptors (refer to the section “Segmented addressing in protected mode”).
The 64-bit extension to the IA-32 architecture was proposed by AMD. Registers were extended to 64 bits, and additionally, eight new general-purpose registers were added. They obtained the names R8 - R15. All registers (including already known registers) can be accessed as 64-bit, 32-bit lower-order half, 16-bit lower-order quarter (word) and 8-bit lower-order byte. Registers are presented in fig.8 and in fig.9. The Eflags register is extended to 64 bits and named Rflags. The upper 32 bits of the Rflags are reserved.
The floating point unit, sometimes referred to as x87, works using eight 80-bit data registers, as presented in figure 10. They are organised as a stack, so data items are pushed into the top register. Calculations are done using the top of the stack and another register, usually the next one. Registers are named ST(0) to ST(7), where ST(0) is the top of the stack; register ST(7) is the bottom. The ST name is another way to refer to ST(0). The registers contain the sign bit, exponent part and significand part, encoded according to the IEEE754 standard. Please refer to the section about data encoding and to the section about the FPU description for details of floating-point instructions.
There are also control and status registers in the Floating Point Unit as presented in figure 11.
FPU instruction pointer, data pointer and last opcode registers are used for cooperation with the main processor. The Tag register (figure 12) holds the 2-bit information of the states of each data register. It helps to manage the stack organisation of the data registers.
The Status Word register contains information about the FPU's current state, including the top of the stack, exception flags, and condition codes (figure 13). The latter ones inform about the result of the last operation, similarly to the flags in the RFlag register.
The Control Word register (figure 14 makes it possible to enable or disable exceptions, control the precision of calculations and rounding of their results. The infinity bit is not meaningful in new processors.
MMX instructions are executed with the use of 64-bit packed data. Intel decided to map MMX registers onto the existing FPU registers. The MMX unit has 8 registers named MM0 - MM7, as presented in figure 15. Because they are physically the same as FPU registers, it is not possible to mix freely MMX and FPU instructions.
SSE instructions are executed with the use of 128-bit packed data. To perform calculations, new 128-bit registers were introduced. The SSE unit has 8 registers named XMM0 - XMM7, as presented in figure 16. Because these registers are separate from all previous ones, there are no conflicts between SSE and other instructions.
To control the behaviour and to provide information about the status of the SSE unit, the MXCSR register is implemented (figure 17). It is a 32-bit register with bits with their functions similar to the FPU unit's Control Word and Status Word registers concatenated together.
The YMM registers are the 256-bit extension to the XMM registers. They are introduced to implement the AVX set of instructions. Additionally, in 64-bit processors, the number of available YMM registers was increased to 16 (figure 18).
ZMM registers are the further extension of XMM registers to 512 bits. In 64-bit machines, 32 of such registers are available (figure 19).
XMM are the physical lower halves of YMM, which are the lower halves of ZMM. Anything written to the XMM register appears in part of the YMM and ZMM registers as presented in figure 20
Together with AVX extension and ZMM registers, eight 16-bit opmask registers were introduced to x64 processors (figure 21). They can be used, e.g. to provide conditional execution or mask several elements of vectors in AVX instructions.
In the x64 architecture, there are additional registers used for control purposes. The CR0, CR2, CR3, CR4, and CR8 registers are used for controlling the operating mode of the processor, virtual and protected memory mechanisms and paging. The debug registers, named DR0 through DR7, control the debugging of the processor’s operations and software. Memory type range registers MTRR can be used to map the address space used for the memory-mapped I/O as non-cacheable. Different processors have different sets of model-specific registers, MSR. There are also machine check registers MCR. They are used to control and report on processor performance, detect and report hardware errors. Mostly, the described registers are not accessible to an application program and are controlled by the operating system, so they will not be described in this book. For more details, please refer to Intel documentation [1].