A, reference

Assembly Language – Wang Shuang

Second, the body

2.1 Flag Register

In the internal registers of the CPU, there is a special register, which has the following three functions: (1) to store some execution results of relevant instructions; (2) to provide behavioral basis for the CPU to execute relevant instructions; This special register, called the flag register, is used to control how the CPU works. The information stored is often called the program state word PSW

Flag registers are different from other registers that store data, where the whole register has one meaning, but Flag registers operate bit by bit, each bit has a different meaning and records specific information

The 1,3,5,12,13,14,15 bits of Flag are not used in the 8086CPU and have no meaning, but the other bits have special meaning

2.1.1 ZF logo

The sixth bit of the flag is ZF, the zero flag bit, which records whether the result of the relevant instruction is 0. If the result is 0, then ZF =1; if not, then ZF =0

In the 8086CPU instruction set, some instructions are executed that affect the flag register, for example: ADD, SUB, MUL, DIV, INC, OR, AND, etc., are mostly operation instructions (to perform logical or arithmetic operations). Some instructions have no effect on flag registers, such as MOV, PUSH, POP, etc., which are mostly transfer instructions. When an instruction is used, Note the full functionality of this directive, including which flag bits of the flag are affected by the result of execution.

2.1.2 PF logo

The second bit of the flag is pF, which is an odd or even flag bit. It records whether the number of 1 bits in the result is even after the execution of the relevant instruction. If the number of 1 is even, then pF =1; if it is odd, then pF =0

2.1.3 SF, mark

Flag is the seventh SF, symbols, record the related instruction execution, the result is a negative, if the result is negative, SF, = 1, if the result is a negative number, SF, = 0 are typically used in the computer complement to represent the data symbols, y a data in the computer can be seen as a signed number, can also be viewed as an unsigned number SF, logo, A CPU record of the results of an operation on a signed number. It records the positive and negative values of the data. If the data is evaluated as a signed number, the result can be determined by SF.

2.1.4 CF logo

Bit 0 of the flag is CF, the carry flag bit. In general, when performing an unsigned number operation, CF records the carry value from the most significant bit of the result to the higher bit, or the borrow value from the higher bit.

2.1.5 OF mark

The eleventh bit OF the flag is OF, the overflow flag bit. In general, OF records whether the result OF a signed number operation overflowed. Of =1

The difference between CF, which is the flag bit that makes sense for the operation OF unsigned numbers, and OF, which is the flag bit that makes sense for the operation OF signed numbers