172k views
0 votes
Sum of three integers stored in the memory (a) Specify memory location using: [ la ] (b) Load immediate integer-1 to register: [ $t1 ] (c) Load immediate integer-2 to register: [ $t2 ] (d) Load Immediate integer-3 to

User Bagrat
by
5.2k points

1 Answer

6 votes

Answer:

#a) Specify the memory location [la]

la $s0, 0xFFFF0010

#b) Load immediate Integer-1 to register

li $t1, 1

#c) Load immediate Integer-2 to register

li $t2, 2

#d) Load immediate Integer-3 to register

li $t3, 3

#e) Store Integer-1 to memory

sw $t1, ($s0)

#f) Store Integer-2 to memory

sw $t2, 4($s0)

#g) Store Integer-3 to memory

sw $t3, 8($s0)

#h) Load Integer-1 from memory to Register

move $t4,$t1

#i) Load Integer-2 from memory to Register

move $t5,$t2

#j) Load Integer-3 from memory to Register

move $t6,$t3

#k) add the three numbers

add $t7,$t4,$t5

add $t7,$t7,$t6

#l) store the result of the addition again to memory

sw $t7, 12($s0)

#m) Load the result of the addition to register

move $t8,$t7

#sum

li $v0, 1

move $a0,$t8

syscall

Step-by-step explanation:

Run the above code and you will get your perfect output.

User Jeromy French
by
4.4k points