Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer Organization and Assembly Language

Similar presentations


Presentation on theme: "Introduction to Computer Organization and Assembly Language"— 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 Question 1 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 Question 1 a. ADD AX, BX ;AX= 4034h, BX=8051h 4034 0100 0000 0011 0100
C SF=1 , ZF=0 , PF=0 , CF=0 , OF=0 By: Nora Alaqeel

8 Question 1 b. NEG AX ;AX= 6431h FFFF 6431 9BCE 1
9BCF SF=1 , ZF=0 , PF=1 , CF=1 , OF=0 By: Nora Alaqeel

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

10 Question 1 d. DEC BL ;BL=01h SF=0 , ZF=1 , PF=1 , CF=not effected , OF=0 By: Nora Alaqeel

11 Question 2 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 Question 2 By: Nora Alaqeel

13 Question 2 By: Nora Alaqeel

14 Question 2 By: Nora Alaqeel

15 Question 2 By: Nora Alaqeel


Download ppt "Introduction to Computer Organization and Assembly Language"

Similar presentations


Ads by Google