Question: In this lab, we write a program in RISC-V assembly language that reverse the order of the bits in a register. The program reads a

 In this lab, we write a program in RISC-V assembly language

In this lab, we write a program in RISC-V assembly language that reverse the order of the bits in a register. The program reads a signed integer from the console and reverse the 32 bits in the number. Skeleton code in reads an integer, using a system call, and saves it in s1. Implement the following steps with RISC-V instructions. - Write a loop to reverse the bits in s1 and save the results in s2. Think aobut the strategy/algorithm first. One method is provided in pseudocode at the bottom of this page. Note that we are working on bits in registers and do not interprete them as signed values. - Use a system call to print s1 in binary. Find the system call number in RARS's help. - Use a system call to print a newline character (ASCII value 10). We can use ' \ ' as the immediate in instructions. - Use a system call to print s2 in binary. - Use a system call to print a newline character. Here are some example inputs/oputs of the program. .globl main .text main: \# use system call 5 to read integer addi a7, x0,5 ecall addi s1,a,0 \# copy to s1 \# TODO \# Add you code here \# reverse bits in s1 and save the results in s2 \# print s1 in binary, with a system call \# print newline \# print s2 in binary \# print newline \# exit exit: addi a7, x0,10 ecall

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!