From 319e53af42b9a2ce0e42e46f8c389eb802f89e0a Mon Sep 17 00:00:00 2001 From: MarcusMedeiros99 Date: Sun, 26 Apr 2020 21:59:07 -0300 Subject: [PATCH] =?UTF-8?q?implementa=C3=A7=C3=A3o=20da=20fun=C3=A7=C3=A3o?= =?UTF-8?q?=20fatorial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.asm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/main.asm b/main.asm index 06525e4..23b4654 100644 --- a/main.asm +++ b/main.asm @@ -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 @@ -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)