Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The NOT is an assembly operator that can be used in RISC - V assembly programs. However, NOT is not listed as a RV 3

The NOT is an assembly operator that can be used in RISC-V assembly programs. However, NOT is not listed as a RV32I operator. This means that the NOT operator is translated into a
different statement. What is the translation of 'not rd, rs1' in RISC-V ISA? Justify why the translation works correctly.
write RISC-V assembly code for placing the following immediate
constants in register a0. Use a minimum number of instructions. Comment each
line of assembly code.
a.-2037
b.4169
c.0xD6A
d.10101101101100000100112
Convert the following high-level code into RISC-V assembly code.
Assume that the signed integer variables a, b, c, d, e and f are in registers t0, t1, t2,
t3, t4 and t5. Use only RV32I operators. Comment each line of assembly code.
if ((a > b) && (c > d)){
e = e /4;
f = f *4;
}
else{
e =(a - b)+(c - d);
f =(a + b)-(c + d);
}
Write a RISC-V assembly function called 'reverse_char()' to reverse an
array of characters. The function takes the base address of the array and the
number of elements as arguments. It should return the base address of the array
as the return value. Comment each line of assembly code
Convert the following 'fibonacci()' function, which calculates the
Fibonacci number recursively, into RISC-V assembly code. The function takes a
number as an argument. Comment each line of assembly code.
int fibonacci (int num){
if (n <=1)
return n;
else
return (fibonacci(n-1)+ fibonacci(n-2));
}
Convert the following high-level code into RISC-V assembly code.
Comment each line of assembly code.
int sum_number(int n){
int result =0;
// calculate n + n-1+...+1
while (n >=1){
result += n;
n--;
}
return result;
}
int swap_sum(int *x, int *y){
// swap numbers
int temp;
temp =*y;
*y =*x;
*x = temp;
// return the sum of number
int sum_x = sum_number(*x);
int sum_y = sum_number(*y);
return sum_x + sum_y;
}

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Identify the critical elements in a performance management system

Answered: 1 week ago

Question

Identify the skills necessary for effective coaching

Answered: 1 week ago