Saturday 31 October 2020

Flag register 8086

Here’s a quick review of iapx8088 processor flags:

Zero flag 

The zero flag is set "1" whenever the result of an (arithmetic or logical) operation is zero. 

For example, 

Mov al,5

Add al -5

These two instructions will produce result 0 and thus will set zero flag, ZF =1.


Also, for following example

Mov al,255

Add al,1

These instructions will produce result 256 which requires 9 bits (1 0000 0000) to store. Least 8 bits are stored in AL register causing the result to be zero in AL, hence the ZF =1. 9th bit of the result is stored in Carry flag.


Carry flag

The Carry flag is set when an operation generates a carry out of the highest bit of the destination operand.

In other words Carry flag is set "1" when an arithmetic or logical operation produces a result greator than the destination operand size.

For example,

Mov al,245

Add al,11

Result 256 can't be placed in one byte register hence the CF becomes 1.


For two byte operands ax,bx,cx etc., the CF becomes 1 when result exceeds the 16 bit destination operand.


• The Sign flag is a copy of the high bit of the destination operand, indicating that it is negative if set and positive if clear. (Zero is a positive number).

• The Overflow flag is set when an instruction generates a result that is outside the signed range of the destination operand.

• The Parity flag is set When an instruction generates an even number of 1's in the low byte of the destination operand.

No comments:

Post a Comment

Effect of ADD and SUB instructions on Flag register-Assembly Language for 8086 processor

Flag Register NOTE: ONE OR MORE FLAGS MAY GET SET OR RESET AFTER AN ARITHMETIC LOGIC INSTRUCTION MOV INSTRUCTION DOESN’T AF...