Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICS312 SET 7 Flags.

Similar presentations


Presentation on theme: "ICS312 SET 7 Flags."— Presentation transcript:

1 ICS312 SET 7 Flags

2 Flags Register Individual bits in the FLAGS register give information about the status of the processor. Status flags - reflect the results of computations (add, subtract, multiply, divided) executed by the processor.

3 Zero Flag and Sign Flag Zero flag (ZF) - the zero flag is set(1) when the result of an arithmetic operation is zero. Sign flag (SF) - the sign flag is set(1) when the result of an arithmetic operation has a 1 in the most significant bit (msb).

4 Overflow Flag (OF) (not used in this course)
Overflow means there has been an unexpected sign change in the result of an arithmetic operation involving signed numbers.  This can happen when two signed numbers with the same sign are added or two numbers of opposite sign are subtracted and the result ends up with the wrong sign. Note this cannot happen when numbers of opposite sign are added, or when numbers of the same sign are subtracted. Overflow is indicated by setting the Overflow Flag.

5 Effect of Instructions on Flags
MOV No effect on flags. INC and DEC Sets all flags, except the CF. (i.e., CF is not affected by INC or DEC.) ADD and SUB Sets all flags. NEG Affects all flags OF is set to 1 if the operand is 8000h or 80h.

6 Examples (1) Given AL = 80h, BL = 81h. Determine the status of the carry and overflow flags the following cases: a. ADD AL, BL b. SUB AL, BL c. SUB BL, AL d. NEG AL

7 Examples (2) Given AL = 7Fh, BL = 01h. Determine the status of all flags in the following cases: a. ADD AL, BL b. SUB AL, BL c. SUB BL, AL

8 Examples (3) Given AX = 0FFFFh, BX = 0001h. Determine the status of all flags in the following cases: a. NEG AX b. ADD AX, BX c. SUB BX, AX d. SUB AX, BX e. INC AX

9 Table of Flag Symbols used in Debugger (which we will cover later):
Status Flags Flag Set (1) Flag Clear (0) CF CY NC ZF ZR NZ SF NG PL OF OV NV

10 Textbook Reading (Jones):
Section  5.1


Download ppt "ICS312 SET 7 Flags."

Similar presentations


Ads by Google