Commit b809aa4a authored by Alan Marchiori's avatar Alan Marchiori
Browse files

after class with example

;
parent 5973f3b6
.data
prompt: .asciiz "N = "
sep: .asciiz "\n"
.text
main:
li $v0, 4
la $a0, prompt
syscall
li $v0, 5
syscall
move $a0, $v0
jal fact
move $s0, $v0
li $v0, 4
la $a0, sep
syscall
li $v0, 1
move $a0, $s0
syscall
li $v0, 10
syscall
fact:
addi $sp, $sp, -8
sw $ra, 0($sp)
sw $a0, 4($sp)
beq $a0, $zero, done
addi $a0, $a0, -1
jal fact
lw $ra, 0($sp)
lw $a0, 4($sp)
mul $v0, $v0, $a0
addi $sp, $sp, 8
jr $ra
done:
li $v0, 1
lw $ra, 0($sp)
#lw $a0, 4($sp)
addi $sp, $sp, 8
jr $ra
.data
prompt: .asciiz "N = "
sep: .asciiz "\n"
.text
main:
li $v0, 4
la $a0, prompt
syscall
li $v0, 5
syscall
move $a0, $v0
jal fact
move $s0, $v0
li $v0, 4
la $a0, sep
syscall
li $v0, 1
move $a0, $s0
syscall
li $v0, 10
syscall
fact:
addi $sp, $sp, -8
sw $ra, 0($sp)
sw $a0, 4($sp)
beq $a0, $zero, done
addi $a0, $a0, -1
jal fact
lw $ra, 0($sp)
lw $a0, 4($sp)
mul $v0, $v0, $a0
addi $sp, $sp, 8
jr $ra
done:
li $v0, 1
lw $ra, 0($sp)
#lw $a0, 4($sp)
addi $sp, $sp, 8
jr $ra
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment