1 / 10

ICS312 SET 7

ICS312 SET 7. Flags. 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. Zero Flag and Sign Flag.

audi
Download Presentation

ICS312 SET 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. Status Flags Flag Set (1) Flag Clear (0) CF CY NC ZF ZR NZ SF NG PL OF OV NV Table of Flag Symbols used in Debugger (which we will cover later):

  10. Textbook Reading (Jones): • Section  5.1

More Related