Question

Write the MIPS assembly code that creates the 32-bit constant 0010 0000 0000 0001 0100 1001...

Write the MIPS assembly code that creates the 32-bit constant 0010 0000 0000 0001 0100 1001 0010 0100two and stores that value to register $t1, and print the value of $t1 to stdout in binary - i.e., as a 32 bit sequence of '1's and '0's (use the MIPS syscall functionality for I/O).

Homework Answers

Answer #1

This constant value is not stored in memory, so we must load it in to the register using only MIPS instructions with immediate values. Unfortunately, immediate values can be at most 16 bits long, and the values that we need to load text more than 16 bits. So, multiple instruction will be needed.

We will begin by loading the 16 upper bits. This can be done with the load upper immediate instruction. This instruction takes the 16 bit immediate argument and stores it in the 16 most significant bits of the register argument, while setting the 16 least significant bits of that register to zero.

Now,we need to load the 16 least significant bits.since we know that the 16 least significant bits of $t1 must be zero after the lui instruction, we may simply add the 16 least significant bits of the target constant to the register using an add immediate instruction.

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
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT