Skip to content

Commit

Permalink
implementação da função fatorial
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusMedeiros99 committed Apr 27, 2020
1 parent 137e3fd commit 319e53a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ exec_op:#preparação para chamada das funções do menu
addi $t8, $zero, 7
beq $t8, $t9, exec_raiz # se operação for 7, raiz
addi $t8, $zero, 9
beq $t8, $t9, exec_fatorial
addi $t8, $zero, 8
beq $t8, $t9, exec_tabuada # se operação for 8, tabuada
Expand All @@ -131,8 +134,26 @@ soma:
add $v0, $a0, $a1
jr $ra
exec_fatorial:
jal fatorial

j print_result

fatorial:
add $t0, $zero, $a0
addi $v0, $zero, 1
fat_loop:
beq $t0, $zero, end_fat
mult $v0, $t0
mflo $v0
addi $t0, $t0, -1
j fat_loop
end_fat:
jr $ra
#------------------------------------------------------------------------------------------
# RAIZ
# v0 = raiz(a0)
Expand Down

0 comments on commit 319e53a

Please sign in to comment.