main:

addi $s0, $zero, 5
add $a0, $s0, $0
jal fact

fact:

addi $as, $0, 12
sub $sp, $sp, $as



addi $s1, $0, 10
addi $s2, $0, 5
mul $s0, $s1, $s2
div $s3, $s1, $s2

addi $t0, $0, 10
addi $t1, $0, 4
sw $t0, 0($t1)

addi $t0, $0, 5
addi $t1, $0, 10
add $t2, $t0, $t1

alem:
addi $ra, $0, 10
addi $t0, $0, 2
addi $t1, $0, 3
jr $ra
add $t2, $t0, $t1


label:
add $s1, $s2, $s3
sub $s1, $s2, $s3
addi $s1, $s2, 100
mult $s1, $s2
div $s1, $s2
mfhi $s1
mflo $s2
and $s1, $s2, $s3
or $s1, $s2, $s3
nor $s1, $s2, $s3
xor $s1, $s2, $s3
andi $s1, $s2, 100
ori $s1, $s2, 100
xori $s1, $s2, 100
sll $s1, $s2, 10
srl $s1, $s2, 10
lw $s1, 100($s2)
lb $s1, 100($s2)
lbu $s1, 100($s2)
sw $s1, 100($s2)
sb $s1, 100($s2)
beq $s1, $s2, label
bne $s1, $s2, label
slt $s1, $s2, $s3
slti $s1, $s2, 100
sltu $s1, $s2, $s3
jr $ra
j label
jal label



fattoriale: 

Fact:
addi $as, $zero, 12
sub $sp, $sp, $as
sw $ra, 0($sp)
sw $fp, 4($sp)
sw $a0, 8($sp)
add $fp, $sp, $zero
bne $a0, $zero, Ric
addi $v0, $zero, 1
j Fine
Ric:
addi $as, $zero, 1
sub $a0, $a0, $as
jal Fact
lw $t0, 8($fp)
mult $v0, $t0
mflo $v0
Fine:
lw $fp, 4($sp)
lw $ra, 0($sp)
addi $sp, $sp, 12
jr $ra
main:
addi $v0, $zero, 5
add $a0, $v0, $zero
jal Fact
add $s0, $v0, $zero










<!--
'######## Altrimenti, stampa la lista
indice = 0
do while indice < indice2
a = riga(indice)
op = left(a,6)
rs = mid(a,7,5)
rt = mid(a,12,5)
if BinToInt(op,1) = 0 then

	tipo = "R"
	rd = mid(a,17,5)
	shamt = mid(a,22,5)
	funct = mid(a,27,6)
	istruzione = idenIstrR(BinToInt(funct,1)) & " " & codRegister(BinToInt(rd,1)) & ", " & codRegister(BinToInt(rs,1)) & ", " & codRegister(BinToInt(rt,1))
	
else

	if BinToInt(op,1) <> 2 and BinToInt(op,1) <> 3 then
	
	tipo = "I"
	oper = BinToInt(op,1)
	oper = idenIstrI(oper)
	imm = mid(a,17)
	
		if oper = "Lw" or oper = "Lb" or oper = "Lbu" or oper = "Sb" or oper = "Sw" then
			istruzione = oper & " " & codRegister(BinToInt(rt,1)) & ", " & BinToInt(imm,0) & "(" & codRegister(BinToInt(rt,1)) & ")"
		else
	istruzione = oper & " " & codRegister(BinToInt(rt,1)) & ", " & codRegister(BinToInt(rs,1)) & ", " & BinToInt(imm,0)
			
		end if
	else
	
	tipo = "J"
	oper = BinToInt(op,1)
	oper = idenIstrJ(oper)
	imm = mid(a,7)
	
	istruzione = oper & " " & BinToInt(imm,1)
		
	end if
end if

%>
<br>
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" ID="Table1">
<tr>
	<td width="40%" align="center" valign="middle" bgcolor="white">
	<font size="1" face="arial">
	<b>Indirizzo 0 x <%=indice*4%></b><br>
	Istruzione di tipo <%=tipo%>:<br>
	</font>
	<font size="3" face="arial">
	<b><%=istruzione%></b>	
	</font>
	</td>
</tr>
<tr>
	<td width="60%" bgcolor="#cccccc" valign="top" align="center">
	<%if tipo = "R" then%>
	<table width="280" cellpadding="2" cellspacing="0" style="border:1px solid #666666" ID="Table2">
	<tr>
	<td width="20%" align="center"><font size="1"><%=BinToInt(op,1)%></font></td>
	<td width="15%" align="center"><font size="1"><%=BinToInt(rs,1)%></font></td>
	<td width="15%" align="center"><font size="1"><%=BinToInt(rt,1)%></font></td>
	<td width="15%" align="center"><font size="1"><%=BinToInt(rd,1)%></font></td>
	<td width="15%" align="center"><font size="1"><%=BinToInt(shamt,1)%></font></td>
	<td width="20%" align="center"><font size="1"><%=BinToInt(funct,1)%></font></td>
	</tr>
	<tr>
	<td width="20%" align="center"><font size="1"><%=op%></font></td>
	<td width="15%" align="center"><font size="1"><%=rs%></font></td>
	<td width="15%" align="center"><font size="1"><%=rt%></font></td>
	<td width="15%" align="center"><font size="1"><%=rd%></font></td>
	<td width="15%" align="center"><font size="1"><%=shamt%></font></td>
	<td width="20%" align="center"><font size="1"><%=funct%></font></td>
	</tr>
	<tr>
	<td width="20%" align="center"><font size="1">OP</font></td>
	<td width="15%" align="center"><font size="1">RS</font></td>
	<td width="15%" align="center"><font size="1">RT</font></td>
	<td width="15%" align="center"><font size="1">RD</font></td>
	<td width="15%" align="center"><font size="1">SHAMT</font></td>
	<td width="20%" align="center"><font size="1">FUNCT</font></td>
	</tr>
	</table>
	<%end if%>
	<%if tipo = "I" then%>
	<table width="280" cellpadding="2" cellspacing="0" style="border:1px solid #666666" ID="Table3">
	<tr>
	<td width="20%" align="center"><font size="1"><%=BinToInt(op,1)%></font></td>
	<td width="15%" align="center"><font size="1"><%=BinToInt(rs,1)%></font></td>
	<td width="15%" align="center"><font size="1"><%=BinToInt(rt,1)%></font></td>
	<td width="50%" align="center"><font size="1"><%=BinToInt(imm,0)%></font></td>
	</tr>
	<tr>
	<td width="20%" align="center"><font size="1"><%=op%></font></td>
	<td width="15%" align="center"><font size="1"><%=rs%></font></td>
	<td width="15%" align="center"><font size="1"><%=rt%></font></td>
	<td width="50%" align="center"><font size="1"><%=imm%></font></td>
	</tr>
	<tr>
	<td width="20%" align="center"><font size="1">OP</font></td>
	<td width="15%" align="center"><font size="1">RS</font></td>
	<td width="15%" align="center"><font size="1">RT</font></td>
	<td width="50%" align="center"><font size="1">IMMEDIATE</font></td>
	</tr>
	</table>
	<%end if%>
	<%if tipo = "J" then%>
	<table width="280" cellpadding="2" cellspacing="0" style="border:1px solid #666666" ID="Table4">
	<tr>
	<td width="20%" align="center"><font size="1"><%=BinToInt(op,1)%></font></td>
	<td width="80%" align="center"><font size="1"><%=BinToInt(imm,1)%></font></td>
	</tr>
	<tr>
	<td width="20%" align="center"><font size="1"><%=op%></font></td>
	<td width="80%" align="center"><font size="1"><%=imm%></font></td>
	</tr>
	<tr>
	<td width="20%" align="center"><font size="1">OP</font></td>
	<td width="80%" align="center"><font size="1">INDIRIZZO</font></td>
	</tr>
	</table>
	<%end if%>
	</td>
</tr>
</table>
<%
indice = indice + 1
loop
%>
-->