Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Matias Tomas Gonzalez
individual-2c2024
Commits
96ab6403
Commit
96ab6403
authored
7 months ago
by
Bruno Ernesto Ventrici
Browse files
Options
Download
Email Patches
Plain Diff
correcciones
parent
45deb04c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
30 deletions
+52
-30
p1/ej1.asm
p1/ej1.asm
+14
-9
p1/ej2.asm
p1/ej2.asm
+38
-21
No files found.
p1/ej1.asm
View file @
96ab6403
...
...
@@ -2,11 +2,12 @@ extern malloc
section
.rodata
; Acá se pueden poner todas las máscaras y datos que necesiten para el ejercicio
%define INDICE_ELEM_SIZE 16
%define INV_ELEM_SIZE 32
%define NOMBRE_OFF 0
%define FUERZA_OFF 20
%define DURABILIDAD_OFF 24
; BR LOS OFFSETS SE PONEN EN BYTES
%define INDICE_ELEM_SIZE 16
; BR 2 BYTES OK
%define INV_ELEM_SIZE 32
; BR NO
%define NOMBRE_OFF 0
; BR OK
%define FUERZA_OFF 20
; BR OK
%define DURABILIDAD_OFF 24
; BR OK
section
.text
; Marca un ejercicio como aún no completado (esto hace que no corran sus tests)
...
...
@@ -78,19 +79,21 @@ es_indice_ordenado:
mov
r12w
,
dx
;primero voy a querer ir obteniendo los elementos del indice para indexar el inventario
.cicloIndice:
cmp
r15w
,
dx
cmp
r15w
,
dx
; BR DX ES VOLATIL Y NO SE PRESERVO EN EL CALL
je
.fin
xor
rdi
,
rdi
xor
rsi
,
rsi
mov
r8w
,
[
r13
]
mov
r9w
,
[
r13
+
16
]
mov
r9w
,
[
r13
+
16
]
; BR SERÍA +2
;preparo la sequence call para llamar al comparador con los dos primeros items
mov
rdi
,
[
r14
+
r8
*
8
]
;indexo el inventario con el indice por el tamaño de los punteros elementos
mov
rsi
,
[
r14
+
r9
*
8
]
call
[
rcx
]
;llamo al comparador, va a retornar el resultado en rax
call
[
rcx
]
; BR ES CALL RCX SIN LOS [] SI LA DIRECCIÓN ESTÁ EN RCX
; BR FALTÓ PRESERVAR RCX (VOLATIL)
;llamo al comparador, va a retornar el resultado en rax
cmp
rax
,
byte
0
;si rax es 1, osea false, retorno dicho valor
je
.fin
...
...
@@ -158,8 +161,9 @@ indice_a_inventario:
;quiero pedir espacio para un array de punteros a item
mov
rax
,
8
;muevo a rax el tamaño de los punteros
mul
dx
mov
rdi
,
rax
mov
rdi
,
rax
; OK
call
malloc
; BR FALTÓ PRESERVAR RSI, RDI, DX QUE SE USAN DESPUES
mov
r12
,
rax
mov
r13
,
0
...
...
@@ -171,6 +175,7 @@ indice_a_inventario:
mov
r15
,
[
rdi
+
r14
*
8
]
mov
[
r12
],
r15
; BR SIEMPRE ESTÁ ESCRIBIENDO EN [R12] YA QUE NO MODIFICA R12 ENTRE CADA ITERACIÓN
add
rsi
,
2
add
rdi
,
8
jmp
.ciclo
...
...
This diff is collapsed.
Click to expand it.
p1/ej2.asm
View file @
96ab6403
...
...
@@ -10,11 +10,15 @@ CONST_32: times 4 dd 32.0
CONST_128:
times
4
dd
128.0
MASK_AMOUNT:
db
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0xFF
SUFFLE_MASK:
db
0x00
,
0x04
,
0x0C
,
0x80
db
0x01
,
0x05
,
0x0D
,
0x80
db
0x02
,
0x06
,
0x0E
,
0x80
db
0x03
,
0x07
,
0x0F
,
0x80
; BR SUFFLE_MASK: db 0x00, 0x04, 0x0C, 0x80
; db 0x01, 0x05, 0x0D, 0x80
; db 0x02, 0x06, 0x0E, 0x80
; db 0x03, 0x07, 0x0F, 0x80
; BR ESTABA AGARRANDO MAL EL AZUL
SUFFLE_MASK:
db
0x00
,
0x04
,
0x08
,
0x80
db
0x01
,
0x05
,
0x09
,
0x80
db
0x02
,
0x06
,
0x0A
,
0x80
db
0x03
,
0x07
,
0x0B
,
0x80
section
.text
...
...
@@ -69,7 +73,7 @@ ej2a:
mov
rbp
,
rsp
; Preservamos los registros no volátiles.
push
r12
; desalineado
push
r12
; desalineado
; BR PARA QUE SI DESPUÉS NO SE USAN?
push
r13
; alineado
;cargo las mascaras
...
...
@@ -81,10 +85,16 @@ ej2a:
movdqu
xmm12
,
[
CONST_128
]
movdqu
xmm11
,
[
CONST_32
]
movdqu
xmm9
,
[
MASK_AMOUNT
]
movd
xmm10
,
r8d
pand
xmm10
,
xmm9
;Limpio los valores superiores en caso de que haya basura
pmovzxbd
xmm10
,
xmm10
;movdqu xmm9, [MASK_AMOUNT]
;movd xmm10, r8d ; BR LA MÁSCARA SOLO ES UN BYTE
;pand xmm10, xmm9 ;Limpio los valores superiores en caso de que haya basura ; BR ESO SOLO LIMPIA EL BYTE MAS SIGNIFICATIVO DE XMM10
;pmovzxbd xmm10, xmm10 ;BR ESTA EXTENDIENDO 4 BYTES A DWORD PERO LA MASCARA SOLO LA TIENE EL BYTE MENOS SIGNIFICATIVO
;cvtdq2ps xmm10, xmm10
; BR UNA FORMA DE CARGAR LA MÁSCARA PARA ESTA SOLUCIÓN:
movzx
r8
,
r8b
; BR EXTENDEMOS DE BYTE A QWORD
movd
xmm10
,
r8d
; BR AHORA EN XMM10 LA DWORD MENOS SIGNIFICATIVA TIENE EL VALOR DE LA MÁSCARA
pshufd
xmm10
,
xmm10
,
0x0
; BR HACEMOS QUE LAS 4 DWORD TENGAN EL VALOR DE LA MÁSCARA CON UN SHUFFLE
cvtdq2ps
xmm10
,
xmm10
xor
r8
,
r8
...
...
@@ -92,34 +102,40 @@ ej2a:
xor
r9
,
r9
.x_loop:
movdqu
xmm1
,
[
rsi
]
movdqu
xmm1
,
[
rsi
]
; BR ES MEJOR LEER UNA SOLA VEZ Y DESPUÉS COPIARLOS
movdqu
xmm2
,
[
rsi
]
movdqu
xmm3
,
[
rsi
]
;Voy a aislar cada canal para trabajarlo por separado
pand
xmm1
,
xmm15
;rojo
[R---, R---, R---, R---]
pand
xmm1
,
xmm15
;rojo
pand
xmm2
,
xmm14
;verde
pand
xmm3
,
xmm13
;azul
;Acomodo cada color la principio
movdqu
xmm4
,
xmm1
psrldq
xmm4
,
3
por
xmm1
,
xmm4
psrldq
xmm4
,
3
por
xmm1
,
xmm4
psrldq
xmm4
,
3
por
xmm1
,
xmm1
;[R,R,R,R,-,-,-,-,-,-,-,-]
; BR xmm1=[000R000R000R000R]
movdqu
xmm4
,
xmm1
; BR xmm4=[000R000R000R000R]
psrldq
xmm4
,
3
; BR xmm4=[000000R000R000R0]
por
xmm1
,
xmm4
; BR xmm1=[000R00RR00RR00RR]
psrldq
xmm4
,
3
; BR xmm4=[000000000R000R00]
por
xmm1
,
xmm4
; BR xmm1=[000R00RR0RRR0RRR]
psrldq
xmm4
,
3
; BR xmm4=[000000000000R000]
;por xmm1, xmm1 ; BR xmm1=xmm1 !!
por
xmm1
,
xmm4
; BR xmm1=[000R00RR0RRRRRRR]
;[R,R,R,R,-,-,-,-,-,-,-,-]
movdqu
xmm4
,
xmm2
psrldq
xmm2
,
1
;acomodo el verde en la primera posicion
psrldq
xmm4
,
3
psrldq
xmm4
,
1
;acomodo el verde en la primera posicion ; BR TAMBIÉN CON XMM4
psrldq
xmm4
,
3
por
xmm2
,
xmm4
psrldq
xmm4
,
3
por
xmm2
,
xmm4
psrldq
xmm4
,
3
por
xmm2
,
xmm4
por
xmm2
,
xmm4
movdqu
xmm4
,
xmm3
psrldq
xmm3
,
2
;acomodo el azul en la primera posicion
psrldq
xmm4
,
2
;acomodo el azul en la primera posicion ; BR TAMBIÉN CON XMM4
psrldq
xmm4
,
3
por
xmm3
,
xmm4
psrldq
xmm4
,
3
...
...
@@ -164,6 +180,7 @@ ej2a:
packuswb
xmm1
,
xmm3
;[RRRR,GGGG,BBBB,0000], pero necesito [RGB0, .. , .., RGB0]
movdqu
xmm6
,
[
SUFFLE_MASK
]
pshufb
xmm1
,
xmm6
;aplico un shffle para acomodar los pixeles
pxor
xmm1
,
xmm8
;fijo el alpha
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment