0% found this document useful (0 votes)
129 views20 pages

FINAL Paper of Computer Organization & Assembly Language (COAL)

Uploaded by

Sohaib E
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views20 pages

FINAL Paper of Computer Organization & Assembly Language (COAL)

Uploaded by

Sohaib E
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

COLLEGE OF COMPUTING AND INFORMATION

SCIENCES
Final-Term Assessment Spring 2021 Semester
106343,106244,245, Computer Organization and
Class Id Course Title
246,247 Assembly Language (COAL)
Program BSCS Campus / Shift Main Campus / Morning
Date 26th April 2021 Total Points 80
Dr. Taha, Dr. Muhammad Naveed,
Duration 03 hours Faculty Name
Ms.Yumna
Student Id 10709 Student Name Mustafa Hasnain
Instructions:
 Filling out Student-ID, Student-Name, Class ID on exam header is mandatory.
 Do not remove or change any part of exam header or question paper.
 Write down your answers in given space or at the end of exam paper with proper title
“Answer for Question# _ _”.
 In answers, only photos of handwritten sheets, with page no. and name on the top, will be
accepted.
 Only PDF format is accepted (Student are advise to install necessary software)
 In case of CHEATING, COPIED material or any unfair means would result in negative marking
or ZERO.
 A mandatory recorded viva session will be conducted to ascertain the quality of answer
scripts where deemed necessary.
 Caution: Duration to perform Final-Term Assessment is 03 hours only including submission
time. Therefore, if you failed to upload answer sheet on LMS (in PDF format) within 03
hours limit, you would be considered as ABSENT/FAILED.
 Attempt ALL questions. All questions carry equal marks.
 Answer all the questions in this question paper.
 Check carefully PDF document before uploading that it has all the answers provided by you
with snapshots if you have in your paper.

Page 1 of 20
1. The PIA is recruiting the flight stewards; they want to build an assembly language program
that can evaluate the height and weight of a person. If it will be in the allowed limit it will
jump to a label “successful” otherwise it will jump to “reject” label. The program should
follow the given steps:

 First, prompt with a “Enter Your Weight” and “Enter Your Height” messages.
 When the user given as input, it will compare with the allowed limits, height should
be greater than 160 cm and the weight should be less than 52 kg.
 If both conditions are true, it will jump to the label “successful” while in the other
case jump to the “reject” label.

Solution

Page 2 of 20
Page 3 of 20
Page 4 of 20
2. Consider CoCIS, wants to make a program that can calculate the total marks obtained by
the student in each semester. For that purpose, we have an 8- bit array on the name of
student, while its elements contain the marks obtained in each course. Now, write an
efficient assembly code that can calculate the sum of the all elements in the array.

Solution

Page 5 of 20
Page 6 of 20
3. As we know that assembly language is always a good choice for hardware, so that we
want to write an assembly language program to operate our AC in this summer. The
program should follow the given steps:
 Take user’s input in the Fahrenheit unit
 Perform temperature unit conversion from Fahrenheit into the Celsius unit, by
using the signed arithmetic expression
Celsius = (Fahrenheit - 32) * 5 / 9
 Implement the given pseudocode into your program
if UserTemp > ThresholdTemp then
call SwitchON
else
call SwitchOFF
end if

Solution

Page 7 of 20
Page 8 of 20
4. (a) Find the values of the registers?
.data
intWord WORD 1234h, 9876h
intBytes BYTE 98h,76h,54h,32h, 10h
intArray WORD 10 DUP(2 DUP(?)),0,0

.code
1. mov eax,DWORD PTR intWord ; EAX = ?
2. mov al,BYTE PTR [intWord+1] ; AL = ?
3. mov ax,WORD PTR [intBytes +2] ; AX = ?
4. mov eax,SIZEOF intArray ; EAX = ?

(b) Find the value of AX after executing the given instructions, while considering the
DS = 5000, AX = 1234, BX = 5678, and the memory address 5000:1100 = KIET.

MOV AX, BX ; AX = ?
MOV AX, [BX] ; AX = ?
SolutionA
.data
intWord WORD 1234h, 9876h
intBytes BYTE 98h,76h,54h,32h, 10h
intArray WORD 10 DUP(2 DUP(?)),0,0

.code
1. mov eax,DWORD PTR intWord ; EAX = 98761234h
2. mov al,BYTE PTR [intWord+1] ; AL = 12h
3. mov ax,WORD PTR [intBytes +2] ; AX = 3254h
4. mov eax,SIZEOF intArray ; EAX = 0000002Ch

SolutionB
AX = 5678
Garbage Value

Page 9 of 20
5. (a) Suppose we are using EAX, EBX, ECX, EDX and ESI registers for data manipulation in our
program. While doing so, the values of these registers are changes frequently, each time within
the loop. Write the most appropriate instructions within this program so that the values of
these 32-bit registers can be saved and restored later easily.

Loop3:
mov esi,OFFSET array
mov ecx,LENGTHOF array
mov ebx,TYPE array
mov eax, ecx
add eax, edx
sub eax, '5'
jz Loop3

(b) On a runtime stack, if the last value is POP at the offset of 00000FF1, then what will be the
value of ESP if we use perform an eight-bit push operation “PUSH AL”?
SolutionA
.code
push esi
push ecx
push ebx

Loop3:
mov esi,OFFSET array
mov ecx,LENGTHOF array
mov ebx,TYPE array
mov eax, ecx
add eax, edx
sub eax, '5'
jz Loop3
pop esi
pop ecx
pop ebx
SolutionB

In the run time stack didn’t have possible bhtes in operation in using of runtime stack

Page 10 of 20
6. Use the below data for the give questions:
.data
var1 BYTE 70h
var2 WORD 6000h
var3 DWORD 0FFFFh
var4 WORD 7FFFh
I. Write an instruction that decrements var2.
II. Write an instruction that subtracts var3 from EAX with destination remains unchanged.
III. Write instructions that AND var2 and var4 with destination remains unchanged.
IV. If var2 is incremented by 1 using the ADD instruction, what will be the values of the Carry
and Sign flags?
V. If var4 is incremented by 1 using the ADD instruction, what will be the values of the
Overflow and Sign flags?

Solution
I. mov bx, var2
dec bx

II. cmp eax, var3

III. test var2, var4

IV. CF = 0 & SF = 0

V. OF = 0 & SF = 0

Page 11 of 20
7. Short scenarios with coding :
a) Can we find out your roll number is even or odd with any Boolean operation, if yes then
show coding?
b) Using some other Boolean instruction rather than compare to find out either operand in
positive, negative or zero.
c) Write instructions that jump to the label THERE if bits 25,26, and 27 are all set in the EDX
register.

SolutionA

Page 12 of 20
SolutionB

Page 13 of 20
Page 14 of 20
Page 15 of 20
8. Identify the mistakes in the following by giving proper reasoning.
(a)
.data
Var1 byte 10
Var2 word 20
.code
Main Proc
movzx al, Var1
movzx bx, Var2
inc Var1
Call writeInt Var1
End Main
End

Page 16 of 20
Page 17 of 20
(b)
.data
V1 sbyte -10
V2 byte 20
.code
Main Proc
Movzx ax, V1
Imul bx, ax, V2
End Main
End

Page 18 of 20
Page 19 of 20
Page 20 of 20

You might also like