Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

GRETSA UNIVERSITY - THIKA

UNIVERSITY EXAMINATIONS
SEP - DEC 2021 SEMESTER

BACHELOR OF SCIENCE IN COMPUTER SCIENCE

COURSE CODE: BSCS 308


COURSE TITLE: ASSEMBLY LANGUAGE

DATE: 18 NOV 2021 TIME: 8.00AM-11.00AM

INSTRUCTIONS TO CANDIDATES

a) SECTION A IS COMPULSORY.
b) SECTION B: ANSWER ANY OTHER THREE QUESTIONS.
c) DO NOT WRITE ANYTHING ON THIS QUESTION PAPER AS IT WILL BE AN
EXAM IRREGULARITY.
d) ALL ROUGH WORK SHOULD BE AT THE BACK OF YOUR ANSWER
BOOKLET AND CROSSED OUT.

CAUTION: All exam rooms are under CCTV surveillance during the examination period.

Page 1 of 4
NOTE: QUESTION ONE -40MARKS

: SECTION B-Each question should be out of 20marks

SECTION A: COMPULSORY

Question ONE

a) You are trying to explain the virtual machine concept to new software development
students. What would you tell them? (2 Marks)
b) What is the 8-bit binary (two’s complement of each of the following signed decimal
integers (4 Marks)
i. 36
ii. -16
c) What is the duration of a single clock cycle in a 3-GHz processor? (2 Marks)
d) You are explaining to a computer hardware class students the CPU flags and are keen
to know the different types of CPU status flags (4 Marks)
e) In your own assessment, why would it be recommendable to use numeric addresses
when writing instructions that access variables (3 Marks)
f) Declare an array of 20 unsigned bytes named bArray and initialize all elements to
zero (5 Marks)
g) Write a program that defines symbolic constants for all of the days of the week.
Create an array variable that uses the symbols as initializers (7 Marks)
h) What will be the hexadecimal value of the destination operand after the following
instructions execute in sequence?
i. mov al, var1 ; a. (2 Marks)
ii. mov ah, [var1 + 3] ; b. (4 Marks)
i) Write statements that cause a program to pause for 700 milliseconds (7 Marks)

SECTION B: ANSWER ANY THREE QUESTIONS

Question TWO
Page 2 of 4
a) You have been tasked to write an assembly language program that asks the user to
enter an integer test score between 0 and 100. The program should display the
appropriate letter grade: (9 Marks)
Score Range Letter Grade

70 to 100 A

60 to 69 B

50 to 59 C

40 to 49 D

Below 40 F

b) Under what circumstances does DAA instruction set the Carry flag? Give an example
(5 Marks)
c) Suppose there were no PUSH instruction. Write a sequence of two other instructions
that would accomplish the same as PUSH EAX. (6 Marks)

Question THREE

a) Write a single instruction (other than NOT) that reverses all bits in EAX (4 Marks
b) Can ESI and EDI registers be used when passing parameters to procedures? Explain
your answer (4 Marks)
c) Use an example to explain the concepts of MSB and LSB in binary (6 Marks)
d) As an assembler for x86 processor family, what three basic types of operands will you
interact with (6 Marks)

Question FOUR

a) Write a program that clears the screen, locates the cursor near the middle of the screen,
prompts the user for two integers, adds the integers, and displays their sum (8 Marks)
b) Use the following to answer the questions that follow:
.data
val1 BYTE 10h

Page 3 of 4
val2 WORD 8000h
val3 DWORD 0FFFFh
val4 WORD 7FFFh
i. Write an instruction that increments val2 (2 Marks)
ii. If val2 is incremented by 1 using the ADD instruction, what will be the values
of the Carry and Sign flags (4 Marks)
iii. If val4 is incremented by 1using the ADD instruction, what will be the values of
the Overflow and Sign flags (6 Marks).

Question FIVE

a) Create and test a procedure named Extended_Sub that subtracts two binary integers of
arbitrary size. Restrictions: The storage size of the two integers must be the same, and
their size must be a multiple of 32 bits. (8 Marks)
b) What is the hexadecimal representation of the following binary numbers (2 Marks)
i. 1001001111101011
ii. 1111111011011011
c) According to you, why is assembly language not preferred in writing large application
problems? (4 Marks)
d) When adding two packed decimal integers of length n bytes, how many storage bytes
must be reserved for the sum? (3 Marks
e) Write a sequence of two instructions that set both the Carry and Overflow flags at the
same time (3 Marks)

Page 4 of 4

You might also like