la, li, and lui Instructions
la rd, mem # load address
li rd, imm # load immediate
lui rd, imm # load upper immediate
la |
li |
lui |
|---|---|---|
.data
msg: .ascii "Class, "
.ascii "Greeting"
.byte 0
.text
la $a0, msg+7
li $v0, 4
syscall
|
.text li $a0, -10+2 li $v0, 1 syscall |
.text lui $a0, 1 li $v0, 1 syscall |
| Output | Output | Output |
li and lui is an expression.
The expression includes several operators such as * (multiplication), / (division), % (remainder), etc.
However, (the instructor believes) the MARS and Spim are not able to handle most expressions, e.g., -10+2 is fine in the above code for Spim, but not for MARS and 10*2 does not work for both simulators.
|
“Take it moment by moment, and you will find that we are all, as I’ve said before, bugs in amber.” ― Kurt Vonnegut |