Reputation: 3
I'm trying to do three things using MIPS, but at the moment do not know where to even start.
I need to write write the value of 0101 0101 0101 0101
into the memory location at address 0x10000000.
Then convert the 16-bit binary value into either decimal or hex in order to include it as part of my code. First put the value into a register, then store the register value at that address in memory.
Then I need to write a value of 1010 1010 1010 1010 1010 1010 1010 1010
into the next memory location, at address 0x10000004
. Again convert the 32-bit binary value. Then first load the upper sixteen bits using lui
, and then the lower sixteen bits using ori
.
Lastly I need to add the values stored at 0x10000000
and 0x10000004
, and store the 32-bit word result at the next address in memory.
Any help will be highly helpful! And explaining the code etc.
Thanks guys
Upvotes: 0
Views: 1329
Reputation: 4961
Try this:
addi $t0 $zero 0x5555 #store 0101 0101 0101 0101 in $t0
lui $t1 0x1000 #store 0x10000000 in $t1
sw $t0 0($t1)
lui $t0 0xAAAA #store 1010 1010 1010 1010 0000 0000 0000 0000 in $t0
ori $t0 0xAAAA #store 1010 1010 1010 1010 1010 1010 1010 1010 in $t0
sw $t0 4($t1)
#load the values, add and store back
lw $t2 0($t1)
lw $t3 4($t1)
add $t4 $t2 $t3
sw $t4 8($t1)
I think maybe what is confusing you is where you are talking about having to convert back and forth between the various bases. As you can see above, this is not necessary.
Upvotes: 1