# copy data from first struct to second
lw $t0,0($s1) # copy age from first
sw $t0,0($s2) # to second struct
lw $t0,__4__($s1) # copy pay from first
sw $t0,__4__($s2) # to second struct
lw $t0,__8__($s1) # copy class from first
sw $t0,__8__($s2) # to second struct
Students who rush through this material often pay for their speed with hours of confusion down the line. Working with addresses and the contents of addresses leads to classic confusions. I speak from experience here, both experience with students and experience in being confused.
The classic prevention to classic confusion is to study a simple program. Such as this one. Copy the program into your editor, paste it to a file and play with it.
The program is more interesting if it writes some output. Here is another block of code to insert just before the end:
# write out the second struct
____ $a0,agest # print "age:"
____ $v0,4
syscall
____ $a0,0($s2) # print age
____ $v0,1
syscall
____ $v0,10 # return to OS
syscall
.data
pay: .word 24000 # rate of pay, in static memory
agest: .asciiz "age: "