1 / 15

Introduction to Computer Organization and Assembly Language

Introduction to Computer Organization and Assembly Language . Sheet 3. The FLAGS Register - Status Flags. Carry Flag (CF): CF = 1 if there is a carry out from the msb on addition. CF = 1 if there is a borrow into the msb on subtraction. CF = 0 otherwise.

ishana
Download Presentation

Introduction to Computer Organization and Assembly Language

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. Introduction to Computer Organization and Assembly Language Sheet 3 By: Nora Alaqeel

  2. The FLAGS Register - Status Flags • Carry Flag (CF): • CF = 1 if there is a carry out from the msb on addition. • CF = 1 if there is a borrow into the msb on subtraction. • CF = 0 otherwise. • CF is also affected by shift and rotate instructions. • Parity Flag (PF): • PF = 1 if the low byte of a result has an even number of one bits • PF = 0 if the low byte has odd parity • (ex. if a result is FFFE PF = 0). By: Nora Alaqeel

  3. The FLAGS Register - Status Flags • Zero Flag (ZF): • ZF = 1 for a zero result. • ZF = 0 for nonzero result. • Sign Flag (SF): • SF = 1 if the msb of a result is 1. • (i.e. Negative if signed interpretation is used). • SF = 0 if the msb is 0. By: Nora Alaqeel

  4. The FLAGS Register - Status Flags • Overflow Flag (OF): • OF = 1 if signed overflow occurred. • OF = 0 otherwise. By: Nora Alaqeel

  5. How Instructions Affect the Flags • In general, each time the processor executes an instruction, the flags • are altered to reflect the result. • However, some instructions don’t affect any of the flags, affects • only some of them, or may leave them undefined. Instruction Affects flags MOV/XCHG none ADD/SUB all INC/DEC all except CF By: Nora Alaqeel

  6. Question1 Q1:For each of the following instructions, give the new destination contents and the new settings of SF,ZF,PF, CF and OF. Suppose that the flags are initially 0 in each part of this question: By: Nora Alaqeel

  7. Question1 • a. ADD AX, BX ;AX= 4034h, BX=8051h 4034 0100 0000 0011 0100 8051 1000 0000 0101 0001 C085 1100 0000 1000 0101 SF=1 , ZF=0 , PF=0 , CF=0 , OF=0 By: Nora Alaqeel

  8. Question1 • b. NEG AX ;AX= 6431h FFFF 6431 9BCE 1 9BCF 1001 1011 1100 1111 SF=1 , ZF=0 , PF=1 , CF=1 , OF=0 By: Nora Alaqeel

  9. Question1 • c. SUB AL, BL ;AL= 34h, BL=51h • 0011 0100 • 51 0101 0001 E31110 0011 SF=1 , ZF=0 , PF=0 , CF=1 , OF=0 By: Nora Alaqeel

  10. Question1 • d. DEC BL ;BL=01h 01 0000 0001 1 0000 0001 00 0000 0000 SF=0 , ZF=1 , PF=1 , CF=not effected , OF=0 By: Nora Alaqeel

  11. Question2 Q2: Write a program to do the following: The program should prompts the user to enter an uppercase letter, then display that letter in lowercase at the same line. Sample Execution: ENTER UPPER CASE LETTER: Aa By: Nora Alaqeel

  12. Question2 By: Nora Alaqeel

  13. Question2 By: Nora Alaqeel

  14. Question2 By: Nora Alaqeel

  15. Question2 By: Nora Alaqeel

More Related