Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ########################################################################
- ### Seja f(x) = 2x + 8. Leia um inteiro n do teclado e calcule f(n). ###
- ########################################################################
- .text
- .globl main
- main: ori $v0, $0, 5 # $v0 = 5. Corresponde à syscall read_int() que guarda o valor devolvido também no $v0.
- syscall # Executa a syscall.
- or $t0, $0, $v0 # $t0 = $v0. Guarda o valor devolvido pelo read_int() no $t0. Representa o x na função f(x) = 2x + 8.
- ori $t2, $0, 8 # $t2 = 8. Representa a constante 8 na função f(x) = 2x + 8.
- add $t1, $t0, $t0 # $t1 = x + x = 2 * x
- add $t1, $t1, $t2 # $t1 = y = (2 * x) + 8
- or $a0, $0, $t1 # $a0 = $t1. Representa o argumento das syscalls print_int10($a0), print_int16($a0), print_int2($a0), print_intu10($a0).
- ori $v0, $0, 1 # $v0 = 1. Corresponde à syscall print_int10($a0). Imprime $a0 em base 10.
- syscall # Executa a syscall
- #ori $v0, $0, 34 # $v0 = 34. Corresponde à syscall print_int16($a0). Imprime $a0 em base 16.
- #syscall # Executa a syscall
- #ori $v0, $0, 35 # $v0 = 35. Corresponde à syscall print_int2($a0). Imprime $a0 em base 2.
- #syscall # Executa a syscall
- #ori $v0, $0, 36 # $v0 = 36. Corresponde à syscall print_intu10($a0). Imprime $a0 em base 10 unsigned (sempre positivo).
- #syscall # Executa a syscall
- jr $ra # Fim
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement