Danimar Baculot IT2104: Property of STI

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Danimar Baculot IT2104

Instructions: Analyze the following simple programs that encompass flag manipulation. Fill the blanks with the correct
comments that would describe the process of the corresponding line of code. Then, answer the following questions in each
program.

Program 1: (2 items x 3 points)


Line 1: ; assume ZF = 0
Line 2: mov al, 55h
Line 3: sub al, 55h ; Subtracting 55h from al
Line 4: push bx
Line 5: mov bx, ax
Line 6: pop dx
Line 7: mov cx, 0
Line 8: inc cx ; Add 1 to the context of CX
_

Questions: (2 items x 2 points)


a. What is the value of ZF in Line 4? ZF = 1
b. What is the value of ZF in Line 6? ZF = 1

Program 2: (3 items x 3 points)


Line 1: parity_encode proc
Line 2: shl al, 2
Line 3: stc ; CF = 1
Line 4: parity_zero:
Line 5: clc ; CF = 0
Line 6: move_parity:
Line 7: rcr al, 3 ; Rotate carry right from AL, 3 _

Line 8: parity_encode endp

Questions: (3 items x 2 points)


a. What is the value of ZF in Line 2? Z=1
b. What is the value of CF after performing the stc operation? CF=1
c. What is the value of CF after performing the operation in Line 7? CF=0

Program 3:
Line 1: include "emu8086.inc" Line 11: not_equal:
Line 2: org 100h Line 12: add bl, al
Line 3: mov al, 5 Line 13: sub al, 10
Line 4: mov bl, 7 Line 14: xor al, bl
Line 5: cmp al, bl Line 15: jmp skip_data
Line 6: jne not_equal Line 16: db 256 dup(0)
Line 7: jmp equal Line 17: skip_data:
Line 8: equal: Line 18: putc 'N'
Line 9: putc 'Y' Line 19: stop:
Line 10: jmp stop Line 20: ret

Questions: (5 items x 2 points)


a. What is the value of the sign flag after performing the cmp operation? SF = 1
b. What is the value of auxiliary flag after performing the cmp operation? AF = 1
c. What is the value of the sign flag in Line 13? SF = 0
d. What is the value of the carry flag in Line 14? CF =1
e. What is the output of the assembly code program? N

06 Activity 1 *Property of STI


Page 1 of 1

You might also like