Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segundo cuatrimestre #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Practica 4 Arq 2022 (1).pdf
Binary file not shown.
18 changes: 18 additions & 0 deletions TP4/Ej10-TP4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.data
cadena: .asciiz "adbdcdedfdgdhdid" ; cadena a analizar
car: .asciiz "d" ; caracter buscado
cant: .word 0 ; cantidad de veces que se repite el caracter car en cadena.

.code
dadd r2, r0, r0
ld r3, car(r0)

loop: ld r4, cant(r0)
lbu r1, cadena(r2)
bne r1, r3, noEsIgual
daddi r4, r4, 1
sd r4, cant(r0)
noEsIgual: daddi r2,r2,1
bnez r1, loop

halt
9 changes: 9 additions & 0 deletions TP4/Ej2-TP4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.data
A: .word 1
B: .word 2
.code
ld r1, A(r0)
ld r2, B(r0)
sd r2, A(r0)
sd r1, B(r0)
halt
11 changes: 11 additions & 0 deletions TP4/Ej3-TP4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.data
A: .word 1
B: .word 3
tabla:
.code
ld r2, B(r0)
ld r1, A(r0)
loop: daddi r2, r2, -1
dsll r1, r1, 1
bnez r2, loop
halt
15 changes: 15 additions & 0 deletions TP4/Ej3c-TP4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.data
A: .word 1
B: .word 3
tabla: .word 0
indice: .word 0
.code
ld r2, B(r0)
ld r1, A(r0)
sd r3, indice(r0)
loop: daddi r2, r2, -1
dsll r1, r1, 1
sd r1,tabla(r3)
daddi r3, r3, 1
bnez r2, loop
halt
17 changes: 17 additions & 0 deletions TP4/Ej4-TP4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.data
tabla: .word 20, 1, 14, 3, 2, 58, 18, 7, 12, 11
num: .word 7
long: .word 10
.code
ld r1, long(r0)
ld r2, num(r0)
dadd r3, r0, r0
dadd r10, r0, r0
loop: ld r4, tabla(r3)
beq r4, r2, listo
daddi r1, r1, -1
daddi r3, r3, 8
bnez r1, loop
j fin
listo: daddi r10, r0, 1
fin: halt
14 changes: 14 additions & 0 deletions TP4/Ej5-TP4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.data
cant: .word 8
datos: .word 1, 2, 3, 4, 5, 6, 7, 8
res: .word 0
.code
dadd r1, r0, r0
ld r2, cant(r0)
loop: ld r3, datos(r1)
daddi r1, r1, 8
dsll r3, r3, 1
sd r3, res(r1)
bnez r2, loop
daddi r2, r2, -1
halt
26 changes: 26 additions & 0 deletions TP4/Ej6-TP4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.data
A: .word 3
B: .word 3
C: .word 3
D: .word 0

.code
ld r1, A(r0) #cargo A
ld r2, B(r0) #CARGO B
ld r3, C(r0) #CARGO C
dadd r4, r0, r0 #Inicializo r4 en 0


bne r1,r2,DISTINTOS1 #jump not equal between A y B
daddi r4, r4, 1 #Case equal add 1 r4 (2 numbers are equal)
DISTINTOS1: bne r1,r3,DISTINTOS2 #jump no equal A y C
daddi r4, r4, 1 #Case equal add 1 r4 (Another number is equal)
DISTINTOS2: bne r2,r3,DISTINTOS3 #B!=C? Jump not equal B y C
daddi r4, r4, 1 #Case equal add 1 r4
DISTINTOS3: daddi r5,r0,1 #Si r4=1 hay DOS numero iguales (R4++)
bne r4,r5, NO_DOS
daddi r4,r4,1

NO_DOS: sd r4, D(r0)
halt
#Si tenes delay slot activado en D queda 4 no 3 porque se ejecuta la instrucción siguiente al salto y luego finaliza
31 changes: 31 additions & 0 deletions TP4/Ej7-TP4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#7) * Escribir un programa que recorra una TABLA de diez números enteros y determine cuántos elementos son mayores que X.
#El resultado debe almacenarse en una dirección etiquetada CANT. El programa debe generar además otro arreglo llamado RES
#cuyos elementos sean ceros y unos. Un ‘1’ indicará que el entero correspondiente en el arreglo TABLA es mayor que X,
#mientras que un ‘0’ indicará que es menor o igual.
.data
X: .word 5
CANT: .word 0
TABLA: .word 3,8,5,3,5,10,11,2,15,0
RES: .word 0

.code

dadd r1,r0,r0 #Desplazamiento (indice)
daddi r2,r0,10 #Cantidad de elementos
dadd r6,r0,r0 #Cantidad de elementos mayores a X

ld r3,X(r0) #r3<-X

LOOP:
ld r5,TABLA(r1)
slt r4,r3,r5 #TABLA[i]>X -> r4 = 1
beqz r4, ES_MENOR
daddi r6,r6,1 #r6++
sd r4,RES(r1)
ES_MENOR:
daddi r1,r1,8
daddi r2,r2,-1
bnez r2,LOOP # Indice != Cantidad de elementos -> LOOP

sd r6,CANT(r0)
halt
23 changes: 23 additions & 0 deletions TP4/Ej8-TP4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#Escribir un programa que multiplique dos números enteros utilizando sumas repetidas (similar a Ejercicio 6 o 7 de la Práctica
#1). El programa debe estar optimizado para su ejecución con la opción Delay Slot habilitada.

.data
NUM1: .word 3
NUM2: .word 5
SUMA: .word 0

.code
ld r1, NUM1(r0) #indice
ld r2, NUM2(r0)
dadd r3, r0, r0 #=SUMA
beqz r1, FIN
beqz r2, FIN


loop:
daddi r1,r1,-1
bnez r1, loop
dadd r3, r3, r2

sd r3, SUMA(r0)
FIN: halt
18 changes: 18 additions & 0 deletions TP4/Ej9-TP4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.data
a: .word 2
x: .word 0
y: .word 3

.code
dadd r2, r0, r0
ld r3, y(r0)

loop: ld r1, a(r0)
beqz r1, fin
daddi r1, r1, -1
dadd r2, r2,r3
sd r1,a(r0)
j loop

fin: sd r2, x(r0)
halt