Answer:
.data
temperature: .space 100 #create space for 25
prompt: .asciiz "\\Enter all temperature for a week of first city and then second city.\\"
city: .asciiz "City "
day: .asciiz ",Day "
colon: .asciiz " : "
display: .asciiz "\\\\Displaying Values:\\"
#declare array
newline: .asciiz "\\" #to print new line
space: .asciiz " " #to print new line
.text
li $v0,4
la $a0,prompt #it will print prompt
syscall
la $s0,temperature #load address of array
li $s1,2 #number of city
li $s2,7 #number of week
li $t0,0 #using as i
outerLoop:
bge $t0,$s1,exitOuter # while i<row
li $t1,0 #using as j
innerLoop:
bge $t1,$s2,exitInner # while i<col
li $v0,4
la $a0,city #it will print prompt
syscall
add $a0,$t0,1
li $v0,1
syscall
li $v0,4
la $a0,day #it will print prompt
syscall
add $a0,$t1,1
li $v0,1
syscall
li $v0,4
la $a0,colon #it will print prompt
syscall
mul $t2,$t0,$s2
add $t2,$t2,$t1 #get address of [i][j]
mul $t2,$t2,4 #get effective address of [i][j]
add $t2,$t2,$s0 #get address of array[i][j]
li $v0,5
syscall
sw $v0,($t2) #load value of array[i][j]
li $v0,11
li $a0,' '
syscall
add $t1,$t1,1 #j++
j innerLoop
exitInner:
li $v0,11
li $a0,'\\'
syscall
add $t0,$t0,1 #i++
j outerLoop
exitOuter:
li $v0,4
la $a0,display
syscall
li $t0,0 #using as i
outerLoop1:
bge $t0,$s1,exitOuter1 # while i<row
li $t1,0 #using as j
innerLoop1:
bge $t1,$s2,exitInner1 # while i<col
li $v0,4
la $a0,city #it will print prompt
syscall
add $a0,$t0,1
li $v0,1
syscall
li $v0,4
la $a0,day #it will print prompt
syscall
add $a0,$t1,1
li $v0,1
syscall
li $v0,4
la $a0,colon #it will print prompt
syscall
mul $t2,$t0,$s2
add $t2,$t2,$t1 #get address of [i][j]
mul $t2,$t2,4 #get effective address of [i][j]
add $t2,$t2,$s0 #get address of array[i][j]
lw $t2,($t2) #load value of array[i][j]
li $v0,1
move $a0,$t2
syscall
li $v0,11
li $a0,'\\'
syscall
add $t1,$t1,1 #j++
j innerLoop1
exitInner1:
li $v0,11
li $a0,'\\'
syscall
add $t0,$t0,1 #i++
j outerLoop1
exitOuter1:
Step-by-step explanation:
The program has been coded in the answer part.
See answer