Instruções MIPS
SISTEMAS DIGITAIS
ALUNO: DIOGO CABRAL DA SILVA
LEI – Instruções MIPS
1.data
str:
.asciiz "Resultado: "
.text
.globl main # Define main como global main: li $s1, 15 li $s2, 36 addi $s3, $zero, 12 addi $s4, $zero, 19 sub $t0, $s1, $s2 #( g - h ) sub $t1, $s3, $s4 #( i - j ) add $s0, $t0, $t1 # ( g - h ) + ( i - j ) li $v0, 4 la $a0, str syscall li $v0, 1 add $a0, $zero, $s0 syscall jr $ra
2.data
.text
.globl main main: addi $s0, $gp, 0 addi $s1, $gp, 2000 addi $s2, $gp, 0 addi $s2, $s2, 60 addi $t0, $zero, 4 dados: sw $t0, 0($s0) addi $s0, $s0, 4 addi $t0, $t0, 4 bne $s0, $s2, dados addi $s0, $gp, 0
transfere: lw $t0, 0($s0) sw $t0, 0($s1) addi $s0, $s0, 4 addi $s1, $s1, 4 bne $s0, $s2, transfere jr $ra
3.data
.text
.globl main main: addi $s0, $gp, 0 addi $s1, $gp, 92 addi $s2, $gp, 0 addi $s2, $s2, 60 addi $t0, $zero, 4 dados: sw $t0, 0($s0) addi $s0, $s0, 4 addi $t0, $t0, 4 bne $s0, $s2, dados addi $s0, $gp, 0 transfere: lw $t0, 0($s0) sw $t0, 0($s1) addi $s0, $s0, 4 addi $s1, $s1, 4 bne $s0, $s2, transfere jr $ra
4.data
.text
.globl main main: addi $s0, $gp, 0 addi $s1, $gp, 2000 addi $s2, $gp, 0 addi $s2, $s2, 40 addi $s3, $gp, 36 addi $t0, $zero, 16
dados: sw $t0, 0($s0) addi $s0, $s0, 4 addi $t0, $t0, 16 bne $s0, $s2, dados addi $s0, $gp, 0 transfere: lw $t0, 0($s0) beq $s0, $s3, divide_ultimo addi $t1, $t0, 1 div $t0, $t1 mflo $t0 sw $t0, 0($s1) addi $s0, $s0, 4 addi $s1, $s1, 4 bne $s0, $s2, transfere divide_ultimo: addi $t1, $t0, 0 div $t0, $t1 mflo $t0 sw $t0, 0($s1) jr $ra
5.data
.text
.globl main main: addi $v0, $zero, 0
#inicializa contador loop: lw $v1, 0($a0)
#le a proxima word de origem sw $v1, 0($a1)
#escreve no destino addi $a0, $a0, 4
#avanca ponteiro para proxima origem addi $a1, $a1, 4
#avanca ponteiro para proximo destino addi $v0, $v0, 1
# incrementa o contador bne $v1, $zero, loop
#repete