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).
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.
Get Answers For Free
Most questions answered within 1 hours.