Please Wait 10 Seconds... OR You CanSkip

## VU CS401 – COMPUTER ARCHITECTURE AND ASSEMBLY MIDTERM EXAMINATION SPRING 2007

.

MIDTERM EXAMINATION

SPRING 2007

CS401 – COMPUTER ARCHITECTURE AND ASSEMBLY

Marks: 45

Time: 90min

LANGUAGE PROGRAMMING (Session – 1 )

Q: Give the new values of AX and DX for each of the following instructions, or tell if

the overflow occurs. [2.5 x 4]

a.

b.

c.

d.

DIV BX, if DX contains 0x0000, AX contains 0x0007, and BX contains 0x0002

DIV BX, if DX contains 0x0000, AX contains 0xFFFF, and BX contains 0x0010

IDIV BX, if DX contains 0xFFFF, AX contains 0xFFFC, and BX contains 0x0003

DIV BX, if DX contains 0xFFFF, AX contains 0xFFFC, and BX contains 0x0003

Q: Fill in the Blanks

[5]

1) In the MOV instruction both operands i.e. source and the destination cannot be

_______________ operands.

2) The MOVZX instruction can be used only with _____________ integers.

3) Consider the following code segment

mov bl,9B

movsx cx,bl

Write down the 16-bit value for cx in the space below

cx

4) Name any two basic type of operands

a. ___________

b. ___________

5) The INC and Dec instruction do not effect the __________ flag

Q: Consider the following pseudo-code and write the corresponding assembly code for

it. [10]

Note: Try to write a shorter code.

If ( al>bl) AND (bl> cl)

{

cx = 1

}

Q: Give the value of the zero flag, the carry flag, the sign flag, and the overflow flag

after each of the following

instructions if AX is initialized with 0x1254 and BX is initialized with 0x0FFF.

[10]

Q:Write a program to swap every pair of bits in the AX register.

For example If AX = 1001100110011001(binary)

Or AX= 0x9999 (hex)

Then after the program execution it must contain this value

AX = 0110011001100110 (binary)

or

AX= 0x6666 (hex)

[10]