Previously, we implemented factorial calculation in MIPS assembly using recursion. Now in this post, we’ll implement factorial calculation using loops only. This program computes factorial of the number entered by the user and prints it.

MIPS (originally an acronym for Microprocessor without Interlocked Pipeline Stages) is a reduced instruction set computer (RISC) instruction set (ISA) developed by MIPS Technologies (formerly MIPS Computer Systems, Inc).

msg1: .asciiz "Enter integer to find factorial: "
.globl main
la $a0,msg1
li $v0,4

li $v0,5
move $a1,$v0
add $a1,$a1,1
li $a0,1                             

jal factorial
li $v0,1
li $v0,10

li $t1,1
bge  $t1,$a1,lab1
mul $a0, $a0,$t1
add $t1,$t1,1
j loop
move $v0,$a0
jr $ra
Tagged with: MIPS AssemblySource Code

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Related News Feeds

Set your Twitter account name in your settings to use the TwitterBar Section.