Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

if this code runs i will upvote and leave a review!! Don't copy other codes In this lab, we write a program in RISC-V assembly

if this code runs i will upvote and leave a review!! Don't copy other codesimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions