Design write and test a program using a procedure to produce
Solution
.data
msg0: .asciiz \"Enter the number of times:\"
msg1: .asciiz \"Enter the first number :\"
msg2: .asciiz \"Enter the second number :\"
newline: .asciiz \"\ \"
.text
main:
li $t0, 1
# calling procedure
jal procedure
# Print output
loop:
# branch condition
bgt $t6,$t4,exit
addi $t6,$t6,1
#pop from stack
lw $t3, 0($sp)
addi $sp, $sp, 4
#print number
addi $v0, $0, 1
add $a0, $t3, $0
syscall
j loop
exit:
li $v0, 10
syscall
procedure:
#print message
li $v0 4
la $a0 msg0
syscall
#read value
li $v0, 5
syscall
move $t4, $v0
#Loop
j loop1
loop1:
bgt $t5,$t4,exit1
#print message
addi $t5,$t5,1
li $v0 4
la $a0 msg1
syscall
# read integer
li $v0, 5
syscall
move $t0, $v0
#print message
li $v0 4
la $a0 msg2
syscall
# read integer
li $v0, 5
syscall
move $t1, $v0
#multiply two numbers
mul $t3,$t1,$t0
addi $sp, $sp, -4
sw $t3, 0($sp)
j loop1
exit1:
li $t0, 3
jr $ra

