Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Clederson Cruz; 2017
- # Realiza conversão de decimal para octal
- #$t0 = valor lido
- #$t1 = expoente
- #$t2 = potencia de 8 acumulada
- #$t3 = b * 8^n
- #$t4 = resultado
- #$s0 = cópia do valor lido
- #$s1 = último dígito de $s0
- .data
- msg1: .asciiz "Informe um valor decimal: "
- msg2: .asciiz "Em octal: "
- .text
- main:
- #Escrevendo a msg na tela
- li $v0, 4
- la $a0, msg1
- syscall
- #Lendo o valor em decimal (inteiro)
- li $v0, 5
- syscall
- add $t0, $v0, $zero #adicionando o valor lido ao registrador $t0
- #***conversão***
- add $s0, $t0, $zero
- mul $t1, $zero, $zero
- add $t2, $zero, 1
- while1: #enquanto a cópia for diferente de zero
- beq $s0, $zero, fimWhile1
- rem $s1, $s0, 10
- div $s0, $s0, 10
- beq $t1, $zero, else
- mul $t2, $t2, 8 #caso nao seja 8^0
- else:
- mul $t3, $t2, $s1
- add $t4, $t4, $t3
- add $t1, $t1, 1
- j while1
- fimWhile1:
- #Exibindo o resultado
- li $v0, 4
- la $a0,msg2
- syscall
- li $v0, 1
- add $a0, $t4, $zero
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement