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
Can someone write a method in MIPS assembly language that asks the user for a hexadecimal...
Can someone write a method in MIPS assembly language that asks the user for a hexadecimal value and converts it into a decimal?
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 a program in MIPS ASSEMBLY LANGUAGE.. Take no of students as input from the user,...
Write a program in MIPS ASSEMBLY LANGUAGE.. Take no of students as input from the user, then take marks of 5 subjects for each student from the user. Then find Minimun, Maximum and Median of all the subjects. and comment each line in code also make flow chart
(MIPS Assembly language) Ask user for two decimal numbers and save to memory (not registers). Multiply...
(MIPS Assembly language) Ask user for two decimal numbers and save to memory (not registers). Multiply these two numbers using adding and shifting only, not the "mul" instruction and print the product to the user as both a base-10 and base-32 (again, no using div/mul/rem). Save the output to a txt file. The program should run 5 times, with no user input needed to continue the program.    
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
Use MARS to write and simulate a MIPS assembly language program to swap two of the...
Use MARS to write and simulate a MIPS assembly language program to swap two of the integers in an integer array. The program should include the Swap function to swap the integers and the main function to call the Swap function. Download the template file “P4_template.asm” provided on Blackboard. Add your code to this file. Do not modify any of the code provided in the file. The main function should: • Pass the starting address of the array in $a0....
Write a MIPS assembly language procedure that simulates/implements the multiplication of two unsigned integers. The procedure...
Write a MIPS assembly language procedure that simulates/implements the multiplication of two unsigned integers. The procedure receives the mulitiplicand and the multiplier and returns the product. IT CANNOT USE A MULTIPLY INSTRUCTION! Write a MIPS assembly language program that demonstrates your multiplication procedure. Your program should ask the user for two integers to multiply. You can assume that the input integers are positive. Adhere to the procedure call convention.
Write a MIPS Assembly Language program to request a name and reflect it back to the...
Write a MIPS Assembly Language program to request a name and reflect it back to the user. The request must be "Please enter your full name:" And it should be output following "The name you entered was: '
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.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT