Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

################################################################################ ## Problem 1 # # Complete the following procedure so that it returns the value of a bit from a # bit vector that

################################################################################ ## Problem 1 # # Complete the following procedure so that it returns the value of a bit from a # bit vector that spans one or more bytes. Register `$a0` holds the start # address of the bit vector and register `$a1` holds the bit number to retrieve. # The most-significant bit of the first byte is bit number 0 (remember that MIPS # is big-endian). The return value (i.e., the value of the register $v0) should # be set to 0 or 1. # For example, a 16-bit bit vector is specified in the assembler below starting # at the label bit_vector_start: # bit_vector_start: # .byte 0xc5, 0x1f # In binary this would be 1100 0101 0001 1111. If getbit were called with $a1=0 # then bit number zero, meaning the leftmost bit in 1100 0101 0001 11112, should # be returned and so $v0=1. For $a1=2 a 0 should be returned. # When you run the code in hw1.s a testbench routine will call getbit several # times. For each call the testbench will print the value returned by getbit # (meaning the value of $v0), whether that value is correct, and if wrong, the # correct value. At the end it will print the number of incorrect values # returned by getbit, which hopefully will be zero when you are done. # It is important that each line of code is commented succinctly with enough # clarity so anyone can follow the logic behind your code. Again writing comment # is part of the solution, code without sufficient comments even if it is # correct, will only receive half of the grade. .text getbit: ## Register Usage # # CALL VALUES # $a0: Address of start of bit vector. # $a1: Bit number to retrieve. # # RETURN # $v0: The bit. (Zero or one.) # # Note: # Can modify registers $t0-$t9, $a0-$a3, $v0, $v1. # DO NOT modify other registers. # # [ ] The testbench should show 0 errors. # [ ] Code should be reasonably efficient. # [ ] The code should be clearly written. # [ ] Comments should be written for an experienced programmer. # write your code here jr $ra nop 

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 Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

How does a process description differ from instructions

Answered: 1 week ago