Docsity

Computer Software Engineering Lab 7: Add Instruction Exercises, Lab Reports of Computer Architecture and Organization

Partial preview of the text

Download Computer Software Engineering Lab 7: Add Instruction Exercises and more Lab Reports Computer Architecture and Organization in PDF only on Docsity!

NUST

Military College of Signals

Rawalpindi.

BATCH-26C

Submitted By:

Aymen Fatima

CMS ID:

Submitted To:

MAM. LARAIB

LAB 7

DEPARTMENT OF COMPUTER SOFTWARE ENGINEERING.

MILITARY COLLEGE OF SIGNALS.

Exercise: 7.1: For each add instruction in this exercise, assume that AX contains the given contents before the instruction is executed. Give the contents of AX as well as the values of the CF, OF, SF, PF, AF and ZF after the instruction is executed. All numbers are in hex. (Hint: add ax, 45 adds 45 to the contents of register ax and stores the result back in ax). Solution: Content of AX (Before) Instruction Content of AX (After) CF OF SF PF AF ZF 0045 add ax, 45 0072 0 0 0 1 1 0 FF45 add ax, 45 FF72 0 0 1 1 1 0 0045 add ax, - 45 0018 1 0 0 1 0 0 FF45 add ax, - 45 FF18 1 0 1 1 0 0 FFFF add ax, 1 0000 1 0 0 1 1 1 Exercise 7.2: In the following instruction sequence, show the values of the Carry, Zero, and Sign flags where indicated: mov al, 01001011b test al, 10100100b ; a. CF= ZF= SF= mov al, 00000110b cmp al, 00000101b ; b. CF= ZF= SF= mov al, 00000101b cmp al, 00000111b ; c. CF= ZF= SF= Solution: (a) CF=0 ; ZF=1 ; SF= (b) CF=0 ; ZF=0 ; SF= (c) CF=1 ; ZF=0 ; SF=