This chapter briefly introduces a register. It paves the way for the following chapters (because I am a lazy person, I have not decided when to write the next chapter.)
The flag register (PSW) is used to save the calculation results and certain states of the CPU.
In order to achieve some functions, when the CPU executes certain instructions, it will save some of the calculation results to the flag register, which are generally arithmetic instructions. For example, whether the calculation result is positive or negative.
The 186 flag register is 16 bits. Except for a few unused bits, each bit has a different meaning and name. The name table is as follows:
15 | 14 | 13 | 12 | 11 | 10 | 09 | 08 | 07 | 06 | 05 | 04 | 03 | 02 | 01 |00
[ ][ ][ ][ ][OF][DF][IF ][TF ][SF][ZF][ ][AF][ ][PF][ ][CF]
[Bit 0 CF]
This is used to record the bit of data that exceeds the bounds after the relevant instruction is executed.
For example:
when adding:
mov ah,10000000B
mov al,10000000B
add ah,al
Result: ah=00000000B (theoretically there is a 1 in the 9th bit, but ah is an 8-bit register, so the 9th bit is not placed here)
The 9th bit is placed in CF!
When performing subtraction, the value borrowed from the high bit can be calculated:
mov ax, 0000H
sub ax, 0001H
Result: ax = FFFFH (a number is borrowed from the 17th bit, so CF = 1 (indicating a borrow!), if no number is borrowed, CF = 0)
[The second bit PF]
is used to record whether the number of 1s in all bits of the result after the execution of the relevant instruction is an even number, if it is, PF = 1 otherwise PF = 0
[The sixth bit ZF]
is used to record whether the result of the execution of the relevant instruction is 0, if it is 0, ZF = 1 otherwise ZF = 0, for example:
mov AX, 1
sub AX, 1
The result is 0, then ZF = 1
Instructions that affect flag bits, such as add, sub, mul, div, inc, or, and, etc., are mostly calculation instructions, and some have no effect, such as mov, push, pop, etc., most of which are transfer instructions.
[The seventh bit SF]
records whether the result after the instruction is executed is a negative number, if it is a negative number, then = 1 otherwise = 0
[8th bit TF]
If TF=1, the CPU will generate an interrupt after running a line of code. If it is 0, the code will continue to run.
[9th bit IF]
Controls whether to respond to external interrupts. If it is 1, it will respond. If it is 0, it will not respond. The STI instruction can set it to 1, and the CLI instruction can set it to 0.
[10th bit DF]
For some instructions...
[11th bit OF]
Overflow flag. If the calculation result overflows, OF=1, otherwise OF=0
Overflow example:
mov ah,FFh
add ah,FFh
The calculation result is greater than the maximum value that ah can store, and it will overflow.
End of this chapter..
Previous article:Chapter 15 XOR and NOT (X86 Assembly Tutorial)
Next article:Chapter 11 Stack (X86 Assembly Tutorial)
Recommended ReadingLatest update time:2024-11-16 17:51
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Learning PLC is easy - PLC ladder diagram and statement table with pictures (Li Changjun, Zhou Hua)
- How to read electrical control circuit diagrams (Classic best-selling books on electronics and electrical engineering) (Zheng Fengyi)
- Single-chip microcomputer C language programming and simulation
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- The latest KEE courses for 2020 are out, be the first to make an appointment!
- EEWORLD University Hall----Live Replay: 3 hours of practice + analysis: TI engineers take you step by step to fully get started with MSP430
- Share the requirements and characteristics of current detection resistors
- The gap between the actual filter circuit and the simulation is too large
- Modify system time in docker container
- TI DSP bootloader and online upgrade
- Questions about creating schematic package in Orcad
- EEWORLD University Hall----Live Replay: Dadatong helps you unlock the new generation of ADAS technology
- What are the six axes in a six-axis robot?
- Three-phase sensorless sine wave BLDC drive (MS39549 and MS39545)