# Education In Pakistan

## VU CS401 – COMPUTER ARCHITECTURE AND ASSEMBLY LANGUAGE PROGRAMMING (Session – 6 ) MIDTERM EXAMINATION SPRING 2007

.

MIDTERM EXAMINATION

SPRING 2007

CS401 – COMPUTER ARCHITECTURE AND

ASSEMBLY LANGUAGE PROGRAMMING (Session – 6

)

Marks: 45

Time: 90min

Student Name:

Center Name/Code:

Exam Date:

______________________________

______________________________

______________________________

Saturday, May 12, 2007

of the questions:

1. Attempt all questions. Marks are written adjacent to each question.

2. Do not ask any question about the contents of this examination from

any one.

a. If you think that there is something wrong with any of the

questions, attempt it

to the best of your understanding.

b. If you believe that some essential piece of information is

missing, make an

appropriate assumption and use it to solve the problem.

c. Write all steps/instruction for a program,

missing

steps/instructions may lead to deduction of marks.

3. Exam is Closed Book. No handouts or extra material is allowed in

exam hall other than rough sheet which will be provided by the

examiner.

4. All the coding syntax will be based on NASM assembler.

5. No assembly software is allowed in the exam center

For Teacher’s use only

Question

Marks

1 2 3 4 5 Total

Question No: 1

( Marks: 5 )

Write valid instruction(s) to perform each function specified below.

[1×5]

a. Provide instruction to jump to label BELOW if AL contains an even number.

b. Provide instruction to move the value at the top of the stack in IP register

c. Provide instruction to move value of flag register in AX.

d. Provide instruction to divide value of AX by 8.

e. Provide instruction to store 0xFFFF into AX.

Question No: 2

( Marks: 10 )

Implement the following code in assembly language. Assume that we are dealing in signed integers

and try to write shorter code.

if( BX>CX OR BX >VAL1 )

X=1

else

X=2

[10]

Question No: 3

( Marks: 10 )

Write a recursive function in assembly language to calculate the square of an integer by adding it

in

itself using recursive call. You can assume any integer number to calculate the square.

[10]

Question No: 4

( Marks: 10 )

Give short answers to the following questions, each question carries equal marks.

[2×5]

a. What is the maximum memory 8088 can access?

b. What is difference between logical and physical memory?

c. A combination of 8 bits is called a byte. What is the name for 4 bits and for 16 bits?

d. What is the purpose of direction flag?

e. What is an assembly language directive?

Question No: 5

( Marks: 10 )

What will be the value of AX after the execution of each instruction?

Each instruction is independent of others.

If AX=44FF and BX=011F

a. xor ah, bh

[2×5]

b.

c.

d.

e.

ror bx, 2

not ah

and ax, bx

rcl ax, 2 if carry flag =0