Question

Write a program in Mars MIPS Assembly Language that asks the user for an 8-digit hexadecimal...

Write a program in Mars MIPS Assembly Language that asks the user for an 8-digit hexadecimal and then prints out its 32-bit binary representation, the operation of the function, the format (I, R, or J), the fields associated with the format (op, rs, rt, imm, shamt, funct), and the instruction associated with the hexadecimal. All five parts must be written as functions.

Homework Answers

Answer #1

Greetings!!

Code with comments:

.data
mydata: .word 0
prompt: .asciiz "Please enter an eight digit number\n"
out: .asciiz "Equivalent binary number is:"
.text
   la $a0,prompt       #load address of prompt message
   li $v0,4       #parameter for displaying string
   syscall           #system call to display message

   la $a0,mydata       #load address of the data variable
   li $v0,5       #parameter for reading a word
   syscall           #system call for reading from the keyboard
   move $t0,$v0       #copy the number read from the keyboard into the register t0

   la $a0,out       #load the address of out message
   li $v0,4       #parameter for string display
   syscall           #system call for display

   addi   $t1, $zero, 31   # number for right shift
   addi   $t2, $zero, 0   # loop count set to 0
   addi   $t3, $zero, 32   # condition for exit
repeat:
   beq   $t2, $t3,end   #if count is 32,then end
   sllv   $a0, $t0, $t2   #shift the number left by one bit
   srlv   $a0, $a0, $t1   #shift right 31 bits, the left shifted number so that the MSB is available
   li   $v0, 1       #parameter for displaying the bit  
   syscall           #system call for display
   addi   $t2, $t2, 1   #increment loop count
   j repeat       #repeat the loop
end:
li $v0,10           #parameter for termination
syscall               #system call for termination

Output screenshot:

Hope this helps

With function:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a mips assembly language program that asks the user to enter and integer number and...
Write a mips assembly language program that asks the user to enter and integer number and read it. Then ask him to enter a bit position (between 0 and 31) and display the value of that bit.
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal....
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal. 1. Request input data type. 2. Request input data. 3. Request output data type. 4. Output the data. The suggested approach was to take the input data as a string. But I am really lost as to how to process the string and then converting it to another data type. Thanks for the help!
Write and test code in MIPS assembly language program to implement algorithms "The Non-Restoring Algorithm "of...
Write and test code in MIPS assembly language program to implement algorithms "The Non-Restoring Algorithm "of an 8-bit integer the user shoud insert the number then by the algo well find the square root
Write an assembly language program that reverses all the bits of a 32-bit number. (Without using...
Write an assembly language program that reverses all the bits of a 32-bit number. (Without using RBIT instruction) Write an assembly language program that checks whether an unsigned number is perfect square or not.
Without using move or li, write MIPS assembly language using MARS simulator to print a half...
Without using move or li, write MIPS assembly language using MARS simulator to print a half pyramid depending on a value n of a user input. Such that if n = 5 were entered the following would be printed: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT