Question

Write a MIPS program with two variables in the .data segment - x and y. The...

Write a MIPS program with two variables in the .data segment - x and y. The program should load x into a register. It should then isolate the last twelve bits of x (the twelve bits furthest to the right). It should finally store the resulting value in the variable y. So, for example, if x contains 1111 0000 1111 0000 1111 0011 1100 1010, your program should store the value 0000 0000 0000 0000 0000 0011 1100 1010 in the variable y.

Please type your answer in the text box below. Don't worry about formatting (spacing, tabs, etc.). Just do your best to make the code as readable as possible.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PROGRAM:

.data
x: .word 0xF0F0F3CA
y: .space 4
prompt: .asciiz "Values of x and y after isolating:\nx = "
prompt1: .asciiz "\ny = "
.text
.globl main
main:
lw $t0,x # Load the value of x into $t0
and $t0,$t0,0x00000FFF # Extract the last 12 bits of x
sw $t0,y # Store the above result in y

li $v0,4 # 4 is the print string syscall
la $a0,prompt # Load the address of the string to be printed
syscall # Print the string

li $v0,35 # 35 is the print integer in binary syscall
lw $a0,x # Load the value to be printed
syscall # Print the integer in binary

li $v0,4 # 4 is the print string syscall
la $a0,prompt1 # Load the address of the string to be printed
syscall # Print the string

li $v0,35 # 35 is the print integer in binary syscall
lw $a0,y # Load the value to be printed
syscall # Print the integer in binary

li $v0,10 # 10 is the exit program syscall
syscall # Exit the program

Please refer to the following screenshot of the program for indentation of the code:

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Write a MIPS program with two variables in the .data segment - x and y. The...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Given A = (1111 0011 1100 0011 1100 0000 0000 0000)2 and assuming A is a...

    Given A = (1111 0011 1100 0011 1100 0000 0000 0000)2 and assuming A is a single precision IEEE-754 floating point number, what decimal value does A represent? Show A in normalized scientific notation: 1.X * 2Y. Convert (28.4)10 to IEEE-754 single-precision binary. Given X = (0100 0010 0000 1111 0000 0000 0000 0000)2 and Y = (0100 0001 1010 0100 0000 0000 0000 0000)2 in single precision IEEE-754 floating point numbers, perform the following operations. Show all of your...

  • Assembly language (MIPS) Let register $8 be x and register $9 be y. Write a program...

    Assembly language (MIPS) Let register $8 be x and register $9 be y. Write a program to evaluate: Z = 3x - 5y+5 Leave the result in register $10. Inspect the register after running the program to check that the program works. Run the program several times, initialize x and y to different values for each run.

  • Introduction: In this lab, you will write a MIPS program to read in (up to) 50...

    Introduction: In this lab, you will write a MIPS program to read in (up to) 50 integer values from the user, store them in an array, print out the amay, one number per line, reverse the elements in the array and finally print out the elements in the just-reversed) array. Feel free to do this lab and all assembly programming labs) in Windows. You must use MARS Getting started: l. In MARS, create a new assembly file with the name...

  • Write a program that will ask the user for a decimal number such as 18 and...

    Write a program that will ask the user for a decimal number such as 18 and prints the 16 bit binary equivalent of the number: 0000 0000 0001 0010 NOTE: Your output should be a binary string formatted by nibbles (spaces every four bits): 0000 0000 0010 1110 1010 0111 1. Ask the user for a number and store it in an int variable called “number”. 2. Find out how many bits you want to use to represent this number....

  • MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and...

    MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and print a simple checksum for each string. Make your string long enough to hold 50 characters. Don't forget to leave space for the null byte. Our checksum algorithm will produce a value which you can print with the syscall for printing a character. Stop reading strings when the user enters ".". The syscall to read a string (sycall code 8) adds a newline to...

  • Given X = (0100 0010 0000 1111 0000 0000 0000 0000)2 and Y = (0100 0001...

    Given X = (0100 0010 0000 1111 0000 0000 0000 0000)2 and Y = (0100 0001 1010 0100 0000 0000 0000 0000)2 in single precision IEEE-754 floating point numbers, perform the following operations. Show all of your work and express the final answer in single precision IEEE 754-floating point representation. 1. X+Y 2. X*Y Hint: show each value in binary normalized scientific notation prior to performing the arithmetic. This should make following the algorithms easier. Rubric: Shows X and Y...

  • Write a program to evaluate the arithmetic expression: (25xy - 10x - 6y + 28)/7 Use...

    Write a program to evaluate the arithmetic expression: (25xy - 10x - 6y + 28)/7 Use symbolic addresses x, y, answer, and remainder. Pick two registers for x and y and load them from memory. At the end of the program, store the answer and remainder to memory. Assume that the values are small enough so that all results fit into 32 bits. Since load delays are turned on in SPIM be careful what instructions are placed in the load...

  • Instruction set architecture R: register X, Y, Opl, Op2: Operand Quantity: constant value EA: Effective memory address Opcode Operation Name MOV X, Y XCH Opl, Op2 ADD X, Y SUB X,Y SAL Op, Quantity...

    Instruction set architecture R: register X, Y, Opl, Op2: Operand Quantity: constant value EA: Effective memory address Opcode Operation Name MOV X, Y XCH Opl, Op2 ADD X, Y SUB X,Y SAL Op, Quantity SAR Op, Quantity Shift Arithmetic Right on Op for Quantity SHR Op Quanti AND X, Y OR X, Y XOR X, Y NOT X LOADR, A LOAD R, (A STORE R, A STORE R, (A Description Move data from Y to X Exchange Op1 with Op2...

  • Implement the following bit sequential Adder-Subtractor design. X and Y are two operand inputs and Z...

    Implement the following bit sequential Adder-Subtractor design. X and Y are two operand inputs and Z is for the control signal i.e. Z is the selection bit. When Z has value 0, the circuit is an adder, meanwhile, the D flip-flop should be initialized to 0 for each addition. When Z has value 1, it performs subtraction, meanwhile, the D flip-flop should be initialized to 1 for each subtraction. Test your Adder-Subtractor circuit on the following operations and use the...

  • A statistical program is recommended. Consider the following data for two variables, x and y. x...

    A statistical program is recommended. Consider the following data for two variables, x and y. x 22 24 26 30 35 40 y 13 20 33 35 40 36 (a) Develop an estimated regression equation for the data of the form ŷ = b0 + b1x. (Round b0 to one decimal place and b1 to three decimal places.) ŷ = (b) Use the results from part (a) to test for a significant relationship between x and y. Use α =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT