CS401 Collection of Old Papers
CS401 Collection of Old Papers
CS401 Collection of Old Papers
com
Instructions
Please read the following instructions carefully before attempting any question:
1. The duration of this examination is 120 minutes.
2. This examination is open Handouts.
3. Answer all questions.
a. There is no choice.
b. You will have to answer correctly all questions in this examination to get the
maximum possible marks.
4. Do not ask any questions about the contents of this examination from anyone.
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.
5. You have been provided with all assembly tools so you can use assembly tools also.
6. Your paper contains 4 questions.
All Coding questions should be answered using the Assembly language syntax.
dd 0x0000FFFF, 0x00CF9A00
ii. 32-bit Read only data segment at level 0, with base at 0x00A0BBBB and limit of
0x1CCCC.
b. Write 32 bit physical addresses for the following accesses where Base = 0x00A00000
and Limit = 0x30000, EBX contains 0x00001000, and ESI contains 0x00003000
i. [bx+si]
ii.[ebx+esi-0x0012FD]
www.vujannat.ning.com
Instructions
Please read the following instructions carefully before attempting any question:
1. The duration of this examination is 150 minutes.
2. This examination is open Handouts.
3. Answer all questions.
a. There is no choice.
b. You will have to answer correctly all questions in this
examination to get the maximum possible marks.
4. Do not ask any questions about the contents of this examination
from anyone.
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.
5. You have been provided with all assembly tools so you can use
assembly tools also.
6. Your paper contains 4 questions.
All Coding questions should be answered using the Assembly language
syntax.
Best of Luck
Write the values of limit A bit , P bit and AVL bit of the following descriptors.
1. dd 0x 00FEADEF , 0x 00B60718
2. dd 0x F8E2135A , 0 x 13DC1258
1. Why we need to disable the interrupts while calling interrupt INT 80hj.
2. Why we need to disable interrupts before we attempt to change the stack (i.e. ss
and sp).
What would be in the variable Find after the execution of the code
given below?
;;-------------------------------------------------------------------------------------------------------------------------------
----
[org 0x0100]
mov cx, [num1]
mov ax, 0
mov [Find], ax
mov ax, 0x4c00
int 0x21
num1: dw 15
Find: dw 0
;;------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------
What will be the values in num1 and num2 after the execution of the
code given below?
;;------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------
[org 0x0100]
mov ax, [num1]
mov bx, [num2]
add ax, bx
sub bx, ax
add ax, bx
num1: dw 5
num2: dw 10
;;------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------
Write a function "ShowResult" that takes the address of two memory locations via the
stack, the one pushed first is the address of an array of integers and the second is the
length of that array. The function should print "Yes" if the array is in ascending order and
"No" if it is not.
Some sample output is shown below,
If array is: Output
5 7 9 13 Yes
15 7 19 13 No
WWW.vujannat.ning.Com
Connecting VU Students
CS401
Final Term Examination – Spring 2006
Time Allowed: 150 Minutes
Explain the purpose and working of the following program. Also, write comments in front of
each instruction describing the purpose of that particular instruction.
[org 0x0100]
jmp start
count: dw 0
attribute: dw 0x07
second: dw 0
timer: push di
push cx
push ax
push es
inc word[cs:count]
cmp word[cs:count], 91
je clrscr
jmp exit
pop es
pop ax
pop cx
pop di
iret
Suppose AL contains 11001011b and CF= 1. Give the new contents of AL after each of the
following instructions is executed.
Assume the preceding initial conditions for each part of this question
a. SHL AL,1
b. SHR AL, 1
c. ROL AL, CL if CL contains 2
d. SAR AL, CL if CL contains 2
e. RCR AL,CL if CL contains 3
Read the following code and tell what will be the final effect on bp value
push bp
mov bp, sp
sub sp, 2
mov bp, sp
pop bp
1. Two's-complement numbers
2. One's-complement numbers
3. All of the given options
4. None of the given options
1. 32 bits
2. 24 bits
3. 16 bits
4. None of the given options
Question No. 8 Marks : 1
StudentID/LoginID: ______________________________
Please read the following instructions carefully before attempting any of the
questions:
1. Paper contains 15 questions in all, 10 MCQs and 5 subjective, attempt all
questions. Marks are written adjacent to each question.
2. Do not ask any question about the contents of this paper 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 reference material is allowed in
exam hall other than rough sheet which will be provided by the examiner.
4. All the coding language should be based on NASM assembler.
5. No assembly software is allowed in the exam center.
6. Use of cell phone during the examination is strictly prohibited, otherwise
strict disciplinary action will be taken as per university rules.
► 16bit
► 32bit
► 64bit
► 20bit
When the subprogram finishes, the ____________________ retrieves the return address from the
stack and transfers control to that location.
► RET instruction
► CALL instruction
► POP instruction
► Jump instruction
► 1 GB
► 6 GB
► 4 GB
► 2 GB
The value of a segment register when the processor is running under protected mode is called
___________________________
► segment descriptor
► segment selector
► global descriptor table
► protected register
► segment registers
► segment selectors
► stack pointers
► register pointers
► low
► medium
► highest
► lowest
► different
► same
► partial
► full
Question No: 9 ( Marks: 1 ) - Please choose one
► 1444k
► 1440k
► 1280k
► 2480k
► 8
► 16
► 4
► 20
Part a)
Calculate the physical memory address generated by the following segment offset pairs. [2 x
2.5]
a. 1DDDh:0436h
b. 1234h:7920h
Part b)
Fill out the corresponding values in HEX in the register table after the execution of each
instruction. Every instruction is dependent on the previous instruction and carry flag is reset in the
start. [2 x 5]
Which BIOS interrupt provides serial port services and list down names of 9 pins of DB-9
connector. [10]
Write a program to print your full name followed by your student ID using bios services.
[10]
Describe the following descriptors. Give its type and the value of all their fields:
dd 01234567h, 789ABCDEh
www.vujannat.ning.com
Instructions
Please read the following instructions carefully before attempting any question:
1. The duration of this examination is 90 minutes.
2. This examination is open Handouts.
3. Answer all questions.
a. There is no choice.
b. You will have to answer correctly all questions in this examination to get the
maximum possible marks.
4. Do not ask any questions about the contents of this examination from anyone.
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.
5. You have been provided with all assembly tools so you can use assembly tools also.
6. Your paper contains 4 questions.
All Coding questions should be answered using the Assembly language syntax.
Write a program named "Countvowels" that counts all occurrences of the vowels in a
source string and then prints the result in the format (vowel, count). For example if the string
is 'afadefsoieaid' it should print (a,3) (e,2) (i,2) (o,1) (u,0) on the screen. The program should
take address of the source string as a parameter via stack. Also provide proper comments
against each instruction.
Note: String is assumed to contain only small case legal letters and length of the string is
fixed to 15 characters. Vowel characters include a, e, i, o, u.
Calculate the first and the last physical memory addresses accessible using each of the
following segment values?
a. FFFF
b. F009
c. 1234
d. 0000
Question No. 4 Marks : 10
Find all the errors in the following code and write those errors against each erroneous
instruction.
Example: push IP ; IP can't be pushed on the stack.
[0x0100]
jmp start
numarray dw 7, 11, 5, 0, 3, 1, 9, 4, 2, 10
index1 0
index2 dw 0
start:
mov ax 0
mov bx, 0
loop:
cmp ax, 20
je num1
mov bh, ax
mov [ index1 ], [ index2]
mov cx, [ numarray + bx ]
add ax, 2
swap:
add bx, 2
cmp bx, 20
je end
cmp cx, [ numarray + bx ]
jc swap
jmp swap
swap:
mov dx, [ numarray + bx ]
mov [ index2 ], bx
mov bx, [ index1 ]
mov [ bp + bx ], dx
mov bx, [ index2 ]
mov [ numarray + bx ], cx
mov cx, dx
jmp start
end:
mov ax, 0x4c00
What will be the value of AX after the execution of each of the following instruction? Each
instruction is independent of others.
If AX= 0x44FF and BX= 0x011F
a. xor ah, bh
b. ror bx, 2
c. not ah
d. and ax, bx
e. rcl ax, 2 if carry flag = 0
www.vujannat.ning.com
i. MOV BL, CX
ii. MOV ES, SS
iii. MOV [BX], [DI]
iv. MOV [BYTEVAR], 20
v. MOV [02], [ 92]
Find errors in the code given below and write error description against each erroneous
instruction.
[org 0x0100]
jmp start
var1 dw 34, 21, 25, 20, 23, 21, 29, 14, 42, 10
var2 dw 0
var3 dw 0
start:
mov 5, 0
mov bx, 0
label1:
cmp ax, 20
je end
mov bh, ax
mov [var2], bx
mov cx, [var1+ bx]
add ax, [bx-si]
label2:
add bx, 2
cmp bx, [bx+bp]
je here
cmp [si+di], cx
jc swap
jmp label2
swap:
mov [var2+bx], [var1+bx]
mov [var3 ], cx
mov bx, [index1]
jmp label2
end:
mov ax, 0x4d00
int 0x21
a) Consider
Write code to replace each lowercase letter in the following string by its upper case
equivalent. Use index address mode.
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]
1) In the MOV instruction both operands i.e. source and the destination cannot be
_______________ operands.
mov bl,9B
movsx cx,bl
cx
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.
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]
a. add ax, 0xEDAB
b. add ax, bx
add bx, 0xF001
MIDTERM EXAMINATION
SPRING 2007 Marks: 45
CS401 - COMPUTER ARCHITECTURE AND Time: 90min
ASSEMBLY LANGUAGE PROGRAMMING (Session - 6
)
StudentID/LoginID: ______________________________
Implement the following code in assembly language. Assume that we are dealing in signed integers
and try to write shorter code. [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]
Give short answers to the following questions, each question carries equal marks.
[2x5]
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?
What will be the value of AX after the execution of each instruction? [2x5]
Each instruction is independent of others.
If AX=44FF and BX=011F
a. xor ah, bh
b. ror bx, 2
c. not ah
d. and ax, bx
e. rcl ax, 2 if carry flag =0