This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:papc:chapter_6_3 [2025/05/09 17:26] – [ZMM registers] ktokarz | en:multiasm:papc:chapter_6_3 [2026/04/01 14:03] (current) – [ZMM registers] ktokarz | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Register Set ====== | ====== Register Set ====== | ||
| + | As x86 processors evolved, the set of available registers and their size expanded. Newer processors added more general-purpose registers, and new registers related to the FPU and vector extensions were added. In this chapter, we discuss the registers available to the programmer, from the 8086 up to modern 64-bit processors. | ||
| ===== x86 registers ===== | ===== x86 registers ===== | ||
| 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 " | 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 " | ||
| Line 5: | Line 6: | ||
| <figure gpregistresx86> | <figure gpregistresx86> | ||
| {{ : | {{ : | ||
| - | < | + | < |
| </ | </ | ||
| Line 23: | Line 24: | ||
| <figure spregistresx86> | <figure spregistresx86> | ||
| - | {{ : | + | {{ : |
| < | < | ||
| </ | </ | ||
| Line 37: | Line 38: | ||
| * CF - Carry flag, set if an operation generates a carry or borrow; for example, if the result of an addition is larger than 16 bits. Used for unsigned arguments. | * CF - Carry flag, set if an operation generates a carry or borrow; for example, if the result of an addition is larger than 16 bits. Used for unsigned arguments. | ||
| * PF - Parity flag, set if the result of an operation contains an even number of bits equal to " | * PF - Parity flag, set if the result of an operation contains an even number of bits equal to " | ||
| - | * AF - Auxiliary Carry flag, similar to CF but informs about the carry or borrow from 3th to the 4th bit. It is used for BCD calculations. | + | * AF - Auxiliary Carry flag, similar to CF but informs about the carry or borrow from the 3rd to the 4th bit. It is used for BCD calculations. |
| * ZF - Zero flag, set if the result of an operation is zero. | * ZF - Zero flag, set if the result of an operation is zero. | ||
| - | * SF - Sign flag, it is a copy of the most significant bit of the result | + | * SF - Sign flag, it is a copy of the most significant bit of the result. |
| * OF - Overflow flag, set if the result of an operation is too large or small to fit in the destination operand. Used for signed arguments. | * OF - Overflow flag, set if the result of an operation is too large or small to fit in the destination operand. Used for signed arguments. | ||
| Line 139: | Line 140: | ||
| </ | </ | ||
| ===== XMM registers ===== | ===== XMM registers ===== | ||
| - | SSE instructions are executed with the use of 128-bit packed data. To perform calculations, | + | SSE instructions are executed with the use of 128-bit packed data. To perform calculations, |
| - | <figure xmmregs> | + | To control the behaviour and to provide information about the status of the SSE unit, the MXCSR register is implemented |
| - | {{ : | + | |
| - | < | + | |
| - | </ | + | |
| - | + | ||
| - | To control the behaviour and to provide information about the status of the SSE unit, the MXCSR register is implemented {{ref> | + | |
| <figure mxcsrreg> | <figure mxcsrreg> | ||
| Line 153: | Line 149: | ||
| </ | </ | ||
| ===== YMM registers ===== | ===== YMM registers ===== | ||
| - | The YMM registers are the 256-bit extension to the XMM registers. They are introduced to implement the AVX set of instructions. Additionally, | + | The YMM registers are the 256-bit extension to the XMM registers. They are introduced to implement the AVX set of instructions. Additionally, |
| - | + | ||
| - | <figure ymmregs> | + | |
| - | {{ : | + | |
| - | < | + | |
| - | </ | + | |
| ===== ZMM registers ===== | ===== ZMM registers ===== | ||
| - | ZMM registers are the further extension of XMM registers to 512 bits. In 64-bit machines, 32 of such registers are available | + | ZMM registers are the further extension of XMM registers to 512 bits. In 64-bit machines, 32 of such registers are available. |
| + | 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 {{ref>xyzmmregs}} | ||
| - | < | + | < |
| - | {{ : | + | {{ : |
| - | < | + | < |
| </ | </ | ||
| + | Together with AVX extension and ZMM registers, eight 16-bit opmask registers were introduced to x64 processors. They can be used, e.g. to provide conditional execution or mask several elements of vectors in AVX instructions. | ||
| - | Together with AVX extension and ZMM registers, eight 16-bit opmask registers were introduced to x64 processors (figure {{ref> | ||
| - | <figure opmaskregs> | ||
| - | {{ : | ||
| - | < | ||
| - | </ | ||
| - | 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 {{ref> | ||
| - | |||
| - | <figure xyzmmregs> | ||
| - | {{ : | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| ===== Additional registers ===== | ===== Additional registers ===== | ||
| In the x64 architecture, | In the x64 architecture, | ||
| 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, | 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, | ||