Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MIPS ASSEMBLY LANGUAGE Write MIPS code to convert binary to decimal : (01110001) 2 to (113) 10 .data binary_digit: .word 0 1 1 1 0

MIPS ASSEMBLY LANGUAGE

Write MIPS code to convert binary to decimal: (01110001)2 to (113)10

.data

binary_digit: .word 0 1 1 1 0 0 0 1 # is 113 in decimal

.globl main

main: # Load arguments to argument registers

# Call convert() # Print return value # (it's in $v0, make sure to copy it before overwriting to print) # Properly end program

convert:

# This label is where conversion of the current array will begin

# Arguments to "functions" in MIPS are passed in on $a# registers # in this case, $a0 = &array[0], $a1 = array.size() # zero the loop counter # zero the return register, i.e. running total

# beginning of loop # If counter >= size, we've iterated every digit and it's time to return the running total # Get bit at current index # Calculate power to raise the current bit to # Multiply current bit by 2^power using shift operation # (Calculate 2^power using multiply loop) # (Remember, sll $reg $reg 1 === $reg = $reg * 2) # Add current_bit * 2^power to running total # Increment index # Start loop again # end of loop

# Jump back to Return Address

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 And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions