Do i have to use the sll instruction?
so in that case would it be
"lw $t0, $sp"
"sll $t0, $t0, 32"
"sw $t0, $sp"
Main Topics
Browse All TopicsThe question goes like this
"The MIPS load-word instruction, lw rt, offset16 (rs), allows specifying a 16-bit offset offset 16 only. Devise a sequence of MIPS instructions, which will be equivalent to the instruction
lw rt, offset32 (rs)
where offset 32 is a 32-bit offset."
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
shifting a 32 bit value left over 32 bits using the sll instruction would leave the value at 0. So that's not really useful.
What the 'lw rt, offset16 (rs)' instruction does is basically :
rt = *(rs + offset16)
where * is the dereference operation ... ie. it gets the value at the calculated address between the ()'s.
That would do :
rt = *(*(rs + offset16) + offset16)
Not really what you want.
I think you are confused by the offset16 vs. offset32. Just consider them variable names. The 16 and 32 merely refer to the maximum size of the value. So, offset16 is a 16 bit integer value that is used as an offset. And offset32 is a 32 bit integer value that is used as an offset.
The question states that :
lw rt, offset(rs)
only works when offset is a 16 bit integer value. How can you make it work with a 32 bit offset too ?
Remember that calculating the offset on an address is basically an addition.
You're looking too far :) It's way simpler than that ... 'add' is really the keyword here ;)
The normal MIPS lw '$t, offset($s)' instruction :
(a) takes the value in the 32 bit register $s
(b) adds the offset to it, which gives a memory address
(c) gets the 32 bit value at that memory address
(d) stores that value in the 32 bit register $t
What if you could split that up in two instructions, and do (a) and (b) with one instruction, and (c) and (d) with another instruction ?
>> i thought that I would need to store the value in $t
The sw instruction is to store a value in memory. $t is a register, so you can simply put it in there with a normal instruction.
In any case, the $t register for the lw instruction will contain the result of the load operation, so you don't need to set it.
Business Accounts
Answer for Membership
by: Infinity08Posted on 2009-09-19 at 14:14:35ID: 25374686
Basically, the offset is just added to the address to calculate the final address. So, if you can calculate the address, and then load the word from that address ... you're all set.