In: Computer Science
Write a MIPS assembly program to implement each of the following operations.
1. DM[6892] = DM[6884]
(Copy the 32-bit data at data memory address 6884 to data memory address 6892.)
2. DM[7968] = DM[6796] + DM[6800]
(Add the 32-bit data at data memory address 6792 and the 32-bit data at data memory address 6800, then store the sum into data memory address 7968.)
Greetings!!
1.
li $t0,6892 #load destination address
li $t1,6884 #load source address
lw $t2,0(t1) #load data from source to t2
sw $t2,0(t0) #store data to destination
Output screenshot:
Before:
Used addresses 10010000 and 10010008 instead of 6892 and 6884
After:Please note that the source remains the same
2.
Code:
li $t0,0x7968 #load destination address
li $t1,0x6796 #load source address 1
li $t2,0x6800 #load source address 2
lw $t3,0($t1) #load data 1
lw $t4,0($t2) #load data 2
add $t4,$t3,$t4 #add data1 and data2
sw $t4,0($t0) #store sum to destination
Output screenshot:
Used addresses 10010000(dest),10010008 and 10010010
Before:
After:
Hope this helps