This la
translates into a lui
followed by a ori
(just as we previously did by hand).
Here is a SPIM example using
la.
To run it in SPIM,
first look in the settings menu and check
"allow pseudo instructions"
and remove the check from "bare machine".
## addEm.asm
## program to add two integers
##
.text
.globl main
main:
la $t0,val2 # put a 32-bit address into $t0
lw $t1,0($t0) # load first value, 2
lw $t2,4($t0) # load second value, 3
addu $t1,$t1,$t2 # calc. sum
.data
val0: .word 0
val1: .word 1
val2: .word 2
val3: .word 3
val4: .word 4
val5: .word 5
## end of addEm.asm
Execute the program by pushing F10 for each machine instruction.