.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 product to 1 li $t3, 0 li $t4, 0 loop: addi $t1, $t1, 1 # increment loop counter by 1 mult $t2, $t1 mfhi $t4 mflo $t2 mul $t3, $t3, $t1 add $t3, $t3, $t4 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, $t3 syscall 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"