Name: Haris Shabbir Section:3B SAP ID: 70077931
Name: Haris Shabbir Section:3B SAP ID: 70077931
SECTION:3B
QUESTION 1
(f) AH = FF, CF = 0 (no carry), ZF = 0 (result not zero), AF = 0 (no auxiliary carry)
QUESTION 2
The data is stored with directive DW. The program will loop 8 times to add the 8 words, and the
loop count is set in data item COUNT, then moved to CX. SI is used to point to the data. As each
word is added to AX, any carry that was generated is added to BX, then the result is stored with
BX as the higher word and AX as the lower word. In this particular example, the result of the
addition is 5CE4H, no carries were generated so the higher word (BX) = 0.
PAGE 60,132
STSEG SEGMENT
DB 64 DUP (?)
STSEG ENDS
;----------------------------
DTSEG SEGMENT
COUNT EQU 08
DATA DW 2300,4300,1200,3700,1298,4323,5673,986
ORG 0010H
SUM DW 2 DUP(?)
DTSEG ENDS
;----------------------------
CDSEG SEGMENT
MOV DS, AX
MAIN ENDP
CDSEG ENDS
END MAIN
QUESTION 3
In order to rewrite Program 3-2 for multibyte addition, the following changes were made:
(1) CX was changed from 4 (to add 4 words) to 8 (to add 8 bytes)
(2) AL was used to accumulate the sum of the two bytes instead of AX
(3) BYTE PTR was used to make the operands match in size
(4) all pointers SI, DI and BX were incremented once to point to the next byte instead of twice
to point to the
next word
PAGE 60,132
STSEG SEGMENT
DB 64 DUP (?)
STSEG ENDS
;----------------------------
DTSEG SEGMENT
DATA1 DQ 548FB9963CE7H
ORG 0010H
DATA2 DQ 3FCD4FA23B8DH
ORG 0020H
DATA3 DQ ?
DTSEG ENDS
;----------------------------
CDSEG SEGMENT
ASSUME CS:CDSEG,DS:DTSEG,SS:STSEG
MOV AX,DTSEG
MOV DS,AX
MAIN ENDP
CDSEG ENDS
END MAIN
QUESTION 4
This program subtracts one 8-byte number from another. The subtraction is performed one byte
at a time, starting at the least significant byte. SBB is used to take care of any borrow that
occurred from the previous byte subtraction. The result of the subtraction is 14C269F4015AH.
PAGE 60,132
STSEG SEGMENT
DB 64 DUP (?)
STSEG ENDS
;----------------------------
DTSEG SEGMENT
DATA1 DQ 548FB9963CE7H
ORG 0010H
DATA2 DQ 3FCD4FA23B8DH
ORG 0020H
DATA3 DQ ?
DTSEG ENDS
;----------------------------
CDSEG SEGMENT
ASSUME CS:CDSEG,DS:DTSEG,SS:STSEG
MOV AX,DTSEG
MOV DS,AX
MOV AH,4CH
MAIN ENDP
CDSEG ENDS
END MAIN
QUESTION 5
The three steps are:
QUESTION 7
(a) DX = E000 CF = 1 ZF = 0
(b) DH = F7 CF = 0 ZF = 0
(c) AL = 76 CF = 0 ZF = 0
(d) DX = E390 CF = 0 ZF = 0
(e) AX = 0 CF = 0 ZF = 1
(f) BX = F7D6 CF = 0 ZF = 0
(g) AH = F0 CF = 0 ZF = 0
(h) AX = F999 CF = 0 ZF = 0
(i) DX = 0D7E CF = 0 ZF = 0
(j) BX = 0000 CF = 0 ZF = 1
(k) AL = 00 CF = 0 ZF = 1
(l) DX = 71C8 CF = 0 ZF = 0
(m) DL = 12 CF = 0 ZF = 0
(n) BX = 8AC0 CF = 0 ZF = 0
(o) DX = E400 CF = 0 ZF = 0
QUESTION 8
(a) CF = 0 and ZF = 0, because 2500 > 1400
(b) CF = 0 and ZF = 0, because FF > 6F
(c) CF = 1 and ZF = 0, because 34 < 88
(d) CF = 0 and ZF = 1, because 0 = 0
(e) CF = 1 and ZF = 0, because 0 < FFFF
(f) CF = 0 and ZF = 1, because FFFF = FFFF
(g) CF = 0 and ZF = 0, because 4000 > 2378
(h) CF = 0 and ZF = 1, because 0 = 0