.text .globl __start __start: li $v0, 4 # mesg1 asking for a number la $a0, msg1 syscall li $v0,5 # system call that reads an integer syscall move $t0, $v0 li $t1, 0 # initialize loop counter li $t2, 1 # initialize total sum to 0 loop: addi $t1, $t1, 1 # increment loop counter by 1 mul $t2, $t2, $t1 # update value of sum beq $t0, $t1, exit # if if counter = N, goto exit label j loop # otherwise loop again exit: li $v0, 4 # print mesg2 la $a0, msg2 syscall li $v0,1 # print factorial move $a0, $t2 syscall li $v0,4 # print an end of line la $a0, cr syscall li $v0,10 # exit syscall .data msg1: .asciiz "Enter a integer number: " msg2: .asciiz "Factorial of the number = " cr: .asciiz "\n"