Four data registers (EAX, EBX, ECX, and EDX)
2 address changes and pointer registers (ESI and EDI) 2 pointer registers (ESP and EBP)
Six segment registers (ES, CS, SS, DS, FS, and GS)
1 Instruction Pointer register (EIP) 1 flag register (EFlags)
1. Data Register
Data registers are mainly used to save information such as the operands and operation results, thus saving the time required to read the operands by occupying the bus and accessing the memory.
The 32-bit CPU has four 32-bit General registers EAX, EBX, ECX, and EDX. Access to low 16-bit data does not affect high 16-bit data. These
The low 16-bit registers are named AX, BX, CX, and DX respectively, which are consistent with the registers in the previous CPU.
4 16-bit registers can be divided into 8 independent 8-bit registers (AX: AH-AL, BX: BH-BL, CX: CH-CL, DX: DH-DL ), each mail
The memory has its own name and can be accessed independently. Programmers can flexibly process words and words by taking advantage of the "severable" feature of data registers.
Section information.
Registers AX and AL are usually called Accumulator. Operations with accumulators may take less time. Accumulators can be used for multiplication,
Operations such as division and input/output are frequently used;
Register BX is called Base Register ). It can be used as a memory pointer;
Register CX is called Count Register ). It is used to control the number of loops during loop and string operations; in-place operations
When multiple digits are removed, CL is used to specify the number of digits;
Register DX is called a Data Register ). During multiplication and division operations, it can be used as the default operand for calculation.
The port address that can be used to store I/O.
In a 16-bit CPU, AX, BX, CX, and DX cannot be used as the base address and address change register to store the address of the storage unit, but in a 32-bit CPU, the 32-bit
Registers EAX, EBX, ECX, and EDX can not only transmit data, store temporary data to save arithmetic logic operation results, but also serve as pointer registers,
Therefore, these 32-bit registers are more universal.
2. Address Change register
The 32-bit CPU has two 32-bit General registers ESI and EDI. Its Low 16-bit value corresponds to the SI and DI in the previous CPU, and does not affect the access to low 16-bit data.
High 16-bit data.
Registers ESI, EDI, SI, and DI are called Index Register, which are mainly used to store the offset of the storage unit in the segment,
They can be used to address multiple storage operations and facilitate access to storage units in different addresses.
The address change register cannot be divided into eight-bit registers. As a general-purpose register, you can also store the operands and results of arithmetic logic operations.
They can be used as general memory pointers. In the execution process of string operation commands, they have specific requirements and
Special features.
3. pointer register
The 32-bit CPU has two 32-bit General registers, EBP and ESP. Its Low 16-bit value corresponds to the same memory and SP in the previous CPU, and its access to low 16-bit data does not affect
High 16-bit data.
Registers EBP, ESP, BP, and SP are known as Pointer Register and are mainly used to store the offset of the storage unit in the stack,
They can be used to address multiple storage operations and facilitate access to storage units in different addresses.
Pointer registers cannot be divided into eight-bit registers. As a general-purpose register, you can also store the operands and results of arithmetic logic operations.
They are mainly used to access the storage units in the stack and stipulate that:
BP is a Base Pointer register that can be used to directly access data in the stack;
SP is the Stack Pointer register, which can only access the top of the Stack.
4. segment register
Segment registers are set based on the management mode of memory segments. The physical address of the Memory Unit is composed of the segment register value and an offset.
In this way, two smaller-digit values can be combined into a memory address that can access a large physical space.
Segment registers inside the CPU:
CS-Code Segment Register (Code Segment Register), whose value is the Segment value of the Code Segment;
DS-Data Segment Register (Data Segment Register), whose value is the Segment value of the Data Segment;
ES -- Extra Segment Register; its value is the Segment value of the additional data Segment;
SS -- Stack Segment Register (Stack Segment Register), whose value is the Segment value of the Stack Segment;
FS -- Extra Segment Register; its value is the Segment value of the additional data Segment;
GS -- Extra Segment Register; its value is the Segment value of the additional data Segment.
In a 16-bit CPU system, it has only four segment registers. Therefore, the program can directly access up to four segments in use at any time.
In a microcomputer system, it has six segment registers. Therefore, programs developed in this environment can access up to six segments at the same time.
The 32-bit CPU has two different ways of working: real-time mode and protection mode. In each mode, segment registers have different functions. Simple Regulations
The ticket is described as follows:
Implementation Method: CS, DS, ES, and SS of the first four segments are exactly the same as those of the previous CPU segments. The logic of the memory unit
The address is still in the format of "segment value: Offset. To access data in a memory segment, the offset between the register and the storage unit must be used.
Protection Mode: In this mode, the situation is much more complicated. The Block Value loaded into the segment register is not a segment value, but a value called "Selector ..
5. Instruction Pointer register
The 32-bit CPU extends the instruction pointer to 32-bit and records it as an EIP. The 16-bit low of the EIP works the same as the IP address in the previous CPU.
The EIP and Instruction Pointer are the offsets of the commands to be executed next time in the code segment. In scenarios with prefetch commands
In an available system, the next command to be executed is usually prefetch to the command queue unless it is transferred. Therefore, when understanding their functions
The command queue is not considered.
In actual mode, because the maximum range of each segment is 64 K, the high 16 bits in the EIP must be 0. At this time, it is equivalent to only using its low 16 bits
To reflect the execution order of commands in the program.
6. Mark register
I. Operation Result flag
1. Carry mark CF (Carry Flag)
The carry mark CF is used to indicate whether the operation generates carry or borrow digits. If the highest bit of the calculation result produces a carry or borrow digit, the value is 1; otherwise, the value is 0.
This flag is used for addition and subtraction of the number of characters (in bytes), comparison of the number of unsigned values, and shift between words (in bytes, commands that specifically change the CF value.
2. Parity mark PF (Parity Flag)
The parity mark PF is used to reflect the parity of the number of "1" in the calculation result. If the number of "1" is an even number, the PF value is 1; otherwise, the value is 0.
PF can be used for parity check or to generate parity bits. In the process of data transmission, in order to provide the reliability of transmission, if the parity method is adopted, this flag can be used.
3. Auxiliary Carry Flag AF (Auxiliary Carry Flag)
In the following cases, the value of the secondary carry flag AF is set to 1; otherwise, the value is 0:
(1) When the word operation occurs, the lower byte is carried to the high byte or the borrow digit;
(2) When the byte operation occurs, the lower 4 bits are carried to the upper 4 bits or the borrow bits.
For the above 6 operation result flags, in general programming, flags CF, ZF, SF, and OF are frequently used, the use frequency of flag PF and AF is low.
4. Zero Flag (ZF)
The zero sign ZF is used to indicate whether the calculation result is 0. If the calculation result is 0, the value is 1; otherwise, the value is 0. You can use this flag when determining whether the calculation result is 0.
5. Sign SF (Sign Flag)
Symbol mark (SF) is the symbol bit used to reflect the calculation result. It is the same as the highest bit of the calculation result. In a microcomputer system, the signed number uses the complement representation. Therefore, SF also reflects the positive and negative signs of the calculation result. When the calculation result is a positive number, the value of SF is 0; otherwise, the value is 1.
6. Overflow Flag)
Overflow sign OF indicates whether the result OF the addition or subtraction operation OF the number OF symbols overflows. If the calculation result exceeds the range expressed by the current number OF BITs, it is called overflow. The value OF is set to 1. Otherwise, the value OF is cleared to 0.
"Overflow" and "carry" are two different meanings. Do not confuse them. For details, refer to the relevant chapter in the computer composition principles course.
Ii. Status Control flag
The status control flags are used to control CPU operations. They must use special commands to change the status control flags.
1. Tracking mark TF (Trap Flag)
When the trace flag TF is set to 1, the CPU enters the single-step execution mode, that is, each execution of a command generates a single-step interruption request. This method is mainly used for program debugging.
There are no special commands in the command system to change the TF value of the flag, but the programmer can use other methods to change its value.
2. IF (Interrupt-enable Flag)
The interrupt flag IF is used to determine whether the CPU responds to the interrupt requests that can be blocked outside the CPU. However, no matter what the value of this sign is, the CPU must respond to the interrupt requests from the outside of the CPU that cannot be blocked and the interrupt requests generated inside the CPU. The specific provisions are as follows:
(1) When IF = 1, the CPU can respond to the interrupt requests externally blocked by the CPU;
(2) When IF = 0, the CPU does not respond to the interrupt requests that can be blocked outside the CPU.
The CPU command system also has special commands to change the IF value of the flag.
3. Direction sign DF (Direction Flag)
The direction sign (DF) is used to determine the direction in which the pointer register is adjusted when the serial operation command is executed. Specific provisions are provided in section 5.2.11-string operation instructions. In the microcomputer instruction system, special commands are also provided to change the value of the Flag DF.
3. 32-Bit Flag
1. IOPL (I/O Privilege Level)
The I/O privileged flag is expressed by two binary bits, also known as an I/O privileged level field. This field specifies the privileged level required to execute the I/O command. If the current privileged level is less than or equal to the IOPL value, the I/O command can be executed. Otherwise, a protection exception occurs.
2. Nested Task flag NT (Nested Task)
The nested task flag NT is used to control the IRET execution of the interrupt return command. The specific provisions are as follows:
(1) When NT = 0, use the stored values in the stack to restore EFLAGS, CS, and EIP, and perform regular interrupted return operations;
(2) When NT = 1, interrupt return is realized through task conversion.
3. Restart Flag)
The restart mark RF is used to control whether debugging failures are accepted. NOTE: If RF is set to 0, the debugging fault is "accepted"; otherwise, the fault is rejected. After successfully executing a command, the processor sets the RF to 0. When a non-debugging fault is received, the processor sets it to 1.
4. Virtual 8086 Mode mark VM (Virtual 8086 Mode)
If the value of this flag is 1, it indicates that the processor is in the virtual 8086 mode. Otherwise, the processor is in the normal protection mode.
The following figure shows the register composition of 8086: