0% found this document useful (0 votes)
199 views

Assignment 3

This document contains instructions for Assignment 3 for the course EE229 - Computer Organization and Assembly Language. It has 9 questions related to assembly language programming. Students are asked to translate pseudocode to assembly code, write assembly programs to search arrays and calculate Fibonacci numbers, analyze procedures, and perform various operations on registers like XOR, shift, rotate. The assignment is to be submitted as a handwritten solution on November 8, 2019 during class time.
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)
199 views

Assignment 3

This document contains instructions for Assignment 3 for the course EE229 - Computer Organization and Assembly Language. It has 9 questions related to assembly language programming. Students are asked to translate pseudocode to assembly code, write assembly programs to search arrays and calculate Fibonacci numbers, analyze procedures, and perform various operations on registers like XOR, shift, rotate. The assignment is to be submitted as a handwritten solution on November 8, 2019 during class time.
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/ 3

EE229 – COAL Sections A Assignment 3

EE229 – Computer Organization and Assembly Language


Assignment 3
Fall 2019

Maximum Marks: 100 Due Date: 08 November 2019

Instructions:
 Partially or fully copied assignments will be marked as zero.
 Only handwritten solution on A4 page will be accepted.
 Late submissions are not allowed and you can submit the assignment during the class only.
 Include comments in your codes/program for a better understanding.
 For question number 4 there is no need to rewrite the code. Just put the instruction number
and your answer in your solution.

Question Number 1 (5 + 10 = 15 marks)


Translate the following pseudocodes to equivalent assembly language codes. (All the variables are 32
bit unsigned integers)

if( eb > ec AND eb > ed) OR ( ed > ea )


{
X = 1;
}
else
{
X = 2;
}
int array[] = {10,60,20,33,72,89,45,65,72,18};
int sample = 50;
int ArraySize = sizeof array / sizeof sample;
int index = 0;
int sum = 0;
while( index < ArraySize )
{
if( array[index] > sample )
{
sum += array[index];
}
index++;
}

National University of Computer and Emerging Sciences – FAST, CFD Campus 1


EE229 – COAL Sections A Assignment 3

Question Number 2 (10 marks)


Write an assembly language program that will look for the first nonzero value in an array of 16-bit
integers. If it finds one, it displays the value; otherwise, it displays a message stating that a nonzero
value was not found. Use an array of 16 bit integers with at least 6 elements to test your program.

Question Number 3 (4 + 4 + 2 = 10 marks)


a) Write a procedure that receives a number in EAX, counts the number of ones in its binary
representation, and returns this count in BX.
b) Then write another procedure that receives a number in BX and set the PF if the number is
even and clear the PF if number is odd.
c) Write a main program to count the number of 1’s in EAX and set the PF accordingly.

Question Number 4 (10 marks)


In the following code sequence, show the value of AL after each shift or rotate instruction is executed:

a) mov al,0D4h
b) shr al,1 ; AL =
c) mov al,0D4h
d) sar al,1 ; AL =
e) mov al,0D4h
f) sar al,4 ; AL =
g) mov al,0D4h
h) rol al,1 ; AL =
i) mov al,0D4h
j) ror al,3 ; AL =
k) mov al,0D4h
l) rol al,7 ; AL =
m) stc
n) mov al,0D4h
o) rcl al,1 ; AL =
p) stc
q) mov al,0D4h
r) rcr al,3 ; AL =

Question Number 5 (15 marks)


Write a procedure to calculate the sum of an integer array (size of each element can be byte, word or
double word). Use stack method to pass the arguments.

Question Number 6 (15 marks)


Write a program that uses a loop to calculate the first seven values of the Fibonacci number sequence,
described by the following formula:
Fib (1) = 1, Fib (2) = 1, Fib (n) = Fib (n -1) + Fib (n - 2)
Place each value in the EAX register and display it by calling a procedure inside the loop.

National University of Computer and Emerging Sciences – FAST, CFD Campus 2


EE229 – COAL Sections A Assignment 3

Question Number 7 (5 marks)


Suppose there were no PUSH instruction. Write a sequence of other instructions that would
accomplish the same as PUSH EAX.

Question Number 8 (5 marks)


Write an ALP to XOR the upper and lower halves of EAX register.

Question Number 9 (15 marks)


Analyze the procedure below and describe its overall operation in few English statements. The
procedure “WriteChar” from the Irvine32 library is used to print a character.

proc1 PROC
pushad
mov ecx, 8
mov ebx, eax
loop2:
mov edx, 0
shld edx, ebx, 4
rol ebx, 4
cmp dl, 10
jae case2
case1:
add dl, 30h
jmp finish
case2:
add dl, 37h
finish:
mov al, dl
call WriteChar
loop loop2
popad
ret
proc1 ENDP

 Good Luck 

National University of Computer and Emerging Sciences – FAST, CFD Campus 3

You might also like