Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 ) ( 7 . 5 Points ) There is a piece of C ( and its equivalent Matlab ) code that we want

Question 1)(7.5 Points) There is a piece of C (and its equivalent Matlab) code that we want to convert to RISC-V. We expect to see a snapshot of your OUT window like the one below. Follow the steps: A.(0.5 Points) Print to the OUT Window in RVS the following string "Student's number:" followed by your student number. If your student number is 123456789, the printed line will be: Students number: 123456789 B.(0.5 Points) Print the string "Input an integer:" and ask the user for an integer input then store it in x1. C.(2 Points) Write a code for the label loop1 that calculates the integer values of x3 and x4. D.(1 Point) Write a code for the label loop2 that updates the values of x7 and x4. E.(1 Point) Write a code for the label end that breaks compiling procedure. F.(1 Point) Test your code with the integer 5, and print the final value of x4 as the Result=. G.(1.5 Points) Write a report based on your code in the report box, and upload both the assembly code (2Q1_Ans.asm) and a snapshot (2Q1_Snapshot) of the RISC-V OUT window. C code for (x7=1; x7 x1+1; x7++){ for (x8=1; x8 x1; x8++){ x3= x7* x8; x4= x3+ x4;} x4= x4+10; } Matlab code for x7=1:1:x1 for x8=1:1: x1-1 x3= x7* x8; x4= x3+x4; end x4= x4+10; end RISC-V OUT window Question 2)(7.5 Points) There is an algorithm for calculating the GCD (greatest common divisor) of two numbers that we want to convert to RISC-V using recursion. We expect to see a snapshot of your OUT window like the one below. Follow the steps: A.(0.5 Points) Print to the OUT Window in RVS the following string "Friday Lab Section". B.(1 Point) Print characters "Input1:" and "Input2:" and ask the user for two integers, one at a time, then store them in x1 and x2, respectively. C.(0.5 Points) define and initiate auxiliary registers with proper values. D.(2 Points) Write a code for the label gcd that instantiates a recursive function for calculating the greatest common divisor. E.(1 Point) Write a code for the label end that breaks compiling procedure. F.(1 Point) Test your code with integers 119 and 68, and print the final value of GCD= as the result. G.(1.5 Points) Write a report based on your code in the report box, and upload both the assembly code (2Q2_Ans.asm) and a snapshot (2Q2_Snapshot) of the RISC-V OUT window. Greatest common divisor algorithm Input1 must be greater than input2: GCD (input1, input2){ If (input2=0) then return input1; Otherwise: return GCD (input2, remainder of (input1/ input2);} Hint: You need a few more registers as auxiliary variables.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications Dasfaa 2023 International Workshops Bdms 2023 Bdqm 2023 Gdma 2023 Bundlers 2023 Tianjin China April 17 20 2023 Proceedings Lncs 13922

Authors: Amr El Abbadi ,Gillian Dobbie ,Zhiyong Feng ,Lu Chen ,Xiaohui Tao ,Yingxia Shao ,Hongzhi Yin

1st Edition

3031354141, 978-3031354144

Students also viewed these Databases questions

Question

What potential obstacles stand in my way?

Answered: 1 week ago