Cs401 Assignment Solution

VU SR

Page 3 of 4

16-bit Offset Address: 4321 Step1: Converting these to 20-bit addresses

20-bit Segment Address: FFFF0 20-bit Offset Address: 04321

Step2: Performing hexadecimal addition: 20-bit Physical address (in hexadecimal): FFFF0 + 04321 = 104311 [As it is more than 20-bits, so wrap it around, that is, discard the most significant hexadecimal digit] 20-bit Physical address (in binary): 0000 0100 0011 0001 0001 [Each hexadecimal digit can be represented in its 4-bit equivalent binary (as shown above)]

f. FFEF:4421 16-bit Segment Address: FFEF 16-bit Offset Address: 4421 Step1: Converting these to 20-bit addresses

20-bit Segment Address: FFEF0 20-bit Offset Address: 04421

Step2: Performing hexadecimal addition: 20-bit Physical address (in hexadecimal): FFEF0 + 04421 = 104311 [As it is more than 20-bits, so wrap it around, that is, discard the most significant hexadecimal digit] 20-bit Physical address (in binary): 0000 0100 0011 0001 0001 [Each hexadecimal digit can be represented in its 4-bit equivalent binary (as shown above)]

g. 1080:0200 16-bit Segment Address: 1080 16-bit Offset Address: 0200 Step1: Converting these to 20-bit addresses

20-bit Segment Address: 10800 20-bit Offset Address: 00200

Step2: Performing hexadecimal addition: 20-bit Physical address (in hexadecimal): 10800 + 00200 = 10A00 20-bit Physical address (in binary): 0001 0000 1010 0000 0000 [Each hexadecimal digit can be represented in its 4-bit equivalent binary (as shown above)]

Question_3:

ÿ Assembly language code: ;Program to add first five odd numbers without defining these numbers.

[ORG 0x100] mov ax,0 ; initialize AX register with value 0 mov bx,1 ; initialize BX register with value 1 mov cx,5 ; We have to sum 5 numbers so initialize CX with value 5

www.VUSR.net

http://lms.vusr.net

Question no. 1:

(a)  Assemble the following instructions and show the changes in given Accumulator register and flags after each instruction execution.                                                                                           (Marks 5)

MOV AL, 8Bh                       ; CF = ?, SF = ?, PF = ?, ZF = ?

ADD AL, 22h                         ; CF = ?, SF = ?, PF = ?, ZF = ?        

AND Al, 1000101b                ; CF = ?, SF = ?, PF = ?, ZF = ?

OR Al, 9Ah                            ; CF = ?, SF = ?, PF = ?, ZF = ?

XOR AL, 10101011b             ; CF = ?, SF = ?, PF = ?, ZF = ?

TEST AL, 2                            ; CF = ?, SF = ?, PF = ?, ZF = ?

CMP AL, 58                           ; CF = ?, SF = ?, PF = ?, ZF = ?

ADC AL, 11110000b             ; CF = ?, SF = ?, PF = ?, ZF = ?

SHR AL,2                               ; CF = ?, SF = ?, PF = ?, ZF = ?

Question no. 1 (b):                                                                                                                     (Marks 5)

Write a subroutine that can calculate the sum of an array and also save the result into DX.

( Array’s length is 20)

Question no. 2

Write an assembly language code to calculate the factorial of “7” using a subroutine and also attach the final snapshot of your AFD window.                       

                                                                                                                                                  ( Marks:10)

One thought on “Cs401 Assignment Solution

Leave a Reply

Your email address will not be published. Required fields are marked *