Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to do a program in MIPS. It needs to convert a hexadecimal to binary and convert a decimal to hexadecimal. I figured out

I need to do a program in MIPS. It needs to convert a hexadecimal to binary and convert a decimal to hexadecimal. I figured out how to do the decimal to hexadecimal below, but I have no idea on how to do hexadecimal to binary. Could someone help me with the hexadecimal to binary?

This is my Decimal to hexadecimal:

.data

prompt: .asciiz "Enter the decimal number to convert: " ans: .asciiz " Hexadecimal equivalent: " result: .space 8 .text .globl main main: la $a0, prompt

li $v0, 4 syscall

li $v0, 5 syscall move $t2, $v0

la $a0, ans

li $v0, 4 syscall

li $t0, 8 # counter la $t3, result # where answer will be stored Loop:

beqz $t0, Exit # branch to exit if counter is equal to zero

rol $t2, $t2, 4 # rotate 4 bits to the left and $t4, $t2, 0xf # mask with 1111 ble $t4, 9, Sum # if less than or equal to nine, branch to sum addi $t4, $t4, 55 # if greater than nine, add 55 b End

Sum: addi $t4, $t4, 48 # add 48 to result

End:

sb $t4, 0($t3) # store hex digit into result

addi $t3, $t3, 1 # increment address counter addi $t0, $t0, -1 # decrement loop counter

j Loop

Exit:

la $a0, result li $v0, 4 syscall

la $v0, 10 syscall

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

Have roles been defined and assigned?

Answered: 1 week ago

Question

Describe the Indian constitution and political system.

Answered: 1 week ago

Question

Explain in detail the developing and developed economy of India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = X 52+7 - 1)(x+2) dx

Answered: 1 week ago

Question

What is gravity?

Answered: 1 week ago

Question

What is the Big Bang Theory?

Answered: 1 week ago