Created
September 16, 2013 19:53
-
-
Save tonussi/6585698 to your computer and use it in GitHub Desktop.
lab5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.data | |
#arranjo inicializado com elementos nao nulos | |
_array: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3 | |
_size: .word 11 | |
.text | |
.globl main | |
main: | |
jal clear1 #salto para o endereco d0 processamento | |
li $v0, 10 # exit syscall | |
syscall | |
clear1: | |
#inicializacao dos parametros | |
la $a0, _array | |
lw $a1, _size | |
#prologo ---> DEVE CONTER UMA UNICA INSTRUCAO | |
addi $t0, $zero, 0 #valor i = $t0 | |
#corpo do laco | |
Loop1: | |
slt $t3, $t0, $a1 | |
beq $t3, $zero, Exit #se (i>=size) desvia para exit | |
sll $t1, $t0, 2 | |
add $t2, $a0, $t1 | |
sw $zero, 0($t2) | |
addi $t0, $t0, 1 | |
j Loop1 | |
#epilogo | |
Exit: | |
jr $ra #retorna ao programa principal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.data | |
#arranjo inicializado com elementos nao nulos | |
_array: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3 | |
_size: .word 11 | |
.text | |
.globl main | |
main: | |
jal clear2 #salto para o endereco d0 processamento | |
li $v0, 10 # exit syscall | |
syscall | |
clear2: | |
#inicializacao dos parametros | |
la $a0, _array | |
lw $a1, _size | |
#prologo ---> DEVE CONTER UMA UNICA INSTRUCAO | |
add $t0, $zero, $a0 #valor i = $t0 | |
#corpo do laco | |
Loop2: | |
sll $t1, $a1, 2 | |
add $t2, $a0, $t1 | |
slt $t3, $t0, $t2 | |
beq $t3, $zero, Exit | |
#se (i>=size) desvia para exit | |
sw $zero, 0($t0) | |
addi $t0, $t0, 4 | |
j Loop2 | |
#epilogo | |
Exit: | |
jr $ra #retorna ao programa principal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment