6

My textbook says that the MIPS assembler must break large constants into pieces and then reassemble them into a register. And that it uses the $at as a temporary register for

I've been looking for a concrete example of this, does anyone have one?

I've seen some websites say that the la pseudo-instruction converts into instructions using $at, but that doesn't seem to be needed. For example:

la $t0, 0xABCD1234

converts into

lui $t0, 0xABCD
ori $t0, $t0, 0x1234
3
  • Try reading this: cs.umd.edu/class/sum2003/cmsc311/Notes/Mips/load32.html ... it's been about 15 years since I've used MIPS Commented Sep 15, 2015 at 15:26
  • You don't need $at to assemble 32-bit constants in general. You may need it to do branches when the native beq/bgez/bgtz/blez/bltz aren't enough and you need to slt* to build a different predicate. Commented Sep 15, 2015 at 17:07
  • 1
    @TimBiegeleisen the link is no longer working, sadly. Commented Sep 5, 2019 at 11:15

1 Answer 1

4

Here's an example taken from my answer to an earlier question regarding the use of li and lw:

Given the following code:

.data
ten: .word 10

.text 
main:
    lw $t0, ten

SPIM would generate the following instruction sequence for the lw:

0x3c011001  lui $1, 4097                    ; lw $t0,ten
0x8c280000  lw $8, 0($1)

The address of ten is first placed in $1 ($at), and then the value is loaded from that address.

Perhaps sw would be a better example. In the case of lw I suppose you could've expanded the lw into lui $8, 4097 / lw $8, ($8). But in the case of sw you wouldn't want to overwrite $t0 with the address.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.