Question: Description 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

Description

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 lab2.s 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/outputs of the program.

170 00000000000000000000000010101010 01010101000000000000000000000000 20232023 00000001001101001011011101010111 11101010111011010010110010000000 1431655765 01010101010101010101010101010101 10101010101010101010101010101010 -3666 11111111111111111111000110101110 01110101100011111111111111111111 -2010819982 10001000001001010101001001110010 01001110010010101010010000010001

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!