0% found this document useful (0 votes)
62 views2 pages

Computer Organization Assignment

The document describes a computer organization assignment to write RISC-V assembly code that implements iterative and recursive Fibonacci number procedures. Students are instructed to use the Venus online simulator to write code for main, Fib_Iter, and Fib_Recu procedures. Fib_Iter computes the nth Fibonacci number using iteration, while Fib_Recu uses recursion. The code is tested by passing the same argument to both procedures and checking they return the same result. Students must name and submit their assembly code file by the deadline following specified naming conventions.

Uploaded by

maninder mani01
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)
62 views2 pages

Computer Organization Assignment

The document describes a computer organization assignment to write RISC-V assembly code that implements iterative and recursive Fibonacci number procedures. Students are instructed to use the Venus online simulator to write code for main, Fib_Iter, and Fib_Recu procedures. Fib_Iter computes the nth Fibonacci number using iteration, while Fib_Recu uses recursion. The code is tested by passing the same argument to both procedures and checking they return the same result. Students must name and submit their assembly code file by the deadline following specified naming conventions.

Uploaded by

maninder mani01
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/ 2

Computer Organization Assignment (5%)

Fall 2020
Use “venus” online simulator to write and execute the code below using RISC-V Assembly
language. The code consists of three procedures: main, Fib_Iter (Leaf), and Fib_Recu
(Non-Leaf). Notice that the Fib_Iter procedure computes the fibonacci number of integer
“x” (i.e. Fx) using iterations. On the other hand, the Fib_Recu procedure computes Fx using
recursion. Notice that F0 = 0, F1 = 1, and Fx = Fx-1 + Fx-2 for 𝑥 ≥ 2. For example, F2 = F1
+ F0 = 1 + 0 = 1, F3 = F2 + F1 = 1 + 1 = 2, F4 = 3, F5 = 5, F6 = 8, F7 = 13…etc.

In the main procedure, we call the Fib_Iter and Fib_Recu procedures using the same
argument value to check that both procedures return the same correct result. Assume that
both procedures expect argument “x” to be in register x12 and returns the final result in
register x11. Assume that variable “w” in the main procedure is mapped to register x20
and variable “z” in the main procedure is mapped to register x21. You can use any
temporary registers for the variables inside each procedure.

You should test the code using multiple values of variable “x”. You can assume that
variable “x” is always greater than or equal to 0. After testing, save your Assembly code
in a text file named “Student1ID_Student2ID.txt”. For example, if the ID of Student1 is
0000 and the ID of Student2 is 1111, then the file name should be “0000_1111.txt”.

Submission Details:
• Deadline: Saturday 19th of December 2020 at 11:59 PM.
• Approach: The code must be named as mentioned above submitted through Teams.
• Group Size: Maximum of two students per group. Each group should send one file.

Venus Simulator:
• Link to simulator: https://www.kvakil.me/venus/
• User Guide: https://github.com/ThaumicMekanism/venus/wiki
• Fibonacci Number: https://en.wikipedia.org/wiki/Fibonacci_number

C Language Code:

void main ( )
{
int w, z;
w = Fib_Iter(2);
z = Fib_Recu(2);
}
int Fib_Iter (int x)
{
int Fib_f, Fib_s, temp, Result;
Fib_f = 0;
Fib_s = 1;
if (x == 0)
Result = Fib_f;
else if (x == 1)
Result = Fib_s;
else
{
while (x >= 2)
{
temp = Fib_f + Fib_s;
Fib_f = Fib_s;
Fib_s = temp;
x--;
}
Result = Fib_s;
}
return Result;
}

int Fib_Recu (int x)


{
if (x == 0)
return 0;
else if (x == 1)
return 1;
else
return (Fib_Recu (x-1) + Fib_Recu (x-2));
}

You might also like