Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Segmento de Dados
- .data
- Num: .word 0
- msg: .asciiz "Introduza um número e pressione Enter\n"
- result: .asciiz "O resultado é: "
- #Iníco do Programa
- .text
- #Imprime a string em msg
- input:
- la $a0, msg
- li $v0, 4
- syscall
- #Lê Num
- li $v0, 5
- syscall
- sw $v0, Num
- #Testa Num
- lw $t0, Num
- beq $t0, $zero, mostra
- add $a1, $a1, $t0
- j input
- #Mostra a string resultado
- mostra:
- la $a0, result
- li $v0, 4
- syscall
- #Mostra o resultado
- move $a0, $a1
- la $v0, 1
- syscall
Add Comment
Please, Sign In to add comment