|
@@ -12,6 +12,9 @@ extern convulcion_matriz
|
|
|
%define radius r8
|
|
%define radius r8
|
|
|
%define cont_c r9
|
|
%define cont_c r9
|
|
|
%define matriz r10
|
|
%define matriz r10
|
|
|
|
|
+%define filas_faltan r11
|
|
|
|
|
+%define col_faltan r12
|
|
|
|
|
+%define basura r13
|
|
|
|
|
|
|
|
; Algunos defines ultiles
|
|
; Algunos defines ultiles
|
|
|
%define PIXEL_SIZE 4
|
|
%define PIXEL_SIZE 4
|
|
@@ -34,6 +37,9 @@ blur_asm:
|
|
|
mov rbp, rsp ; Stack frame
|
|
mov rbp, rsp ; Stack frame
|
|
|
push r9
|
|
push r9
|
|
|
push r10
|
|
push r10
|
|
|
|
|
+ push r11
|
|
|
|
|
+ push r12
|
|
|
|
|
+ push r13
|
|
|
push r14
|
|
push r14
|
|
|
push r15
|
|
push r15
|
|
|
.init:
|
|
.init:
|
|
@@ -66,14 +72,76 @@ blur_asm:
|
|
|
.loop:
|
|
.loop:
|
|
|
cmp cols, cont_c ; Comparo tamaño con el contador
|
|
cmp cols, cont_c ; Comparo tamaño con el contador
|
|
|
je .finFila ; Si ya recorri la imagen voy al final
|
|
je .finFila ; Si ya recorri la imagen voy al final
|
|
|
- ;pxor xmm1,xmm1
|
|
|
|
|
- ;float == dword
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- movd xmm1, [src] ; Cargo la imagen 1 => xmm0 = |B(P1)|G(P1)|R(P1)|A(P1)|B(P2)|G(P2)|......|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ mov filas_faltan, radius;FIXME este radius es pixeles no bytes
|
|
|
|
|
+ add filas_faltan, radius
|
|
|
|
|
+ add filas_faltan, PIXEL_SIZE ; 2r+1 filas
|
|
|
|
|
+ .loopInterno:
|
|
|
|
|
+ mov col_faltan, radius
|
|
|
|
|
+ add col_faltan, radius
|
|
|
|
|
+ add col_faltan, PIXEL_SIZE ; 2r+1 columnas
|
|
|
|
|
+ .loopFila:
|
|
|
|
|
+ ;faltan <4? me muevo para atras 4-faltantes pix
|
|
|
|
|
+
|
|
|
|
|
+ ;levanto 4px
|
|
|
|
|
+ movdqu xmm2, [src] ; Cargo 4 pix de la imagen 1 => xmm0 = |B(P1)|G(P1)|R(P1)|A(P1)|B(P2)|G(P2)|......|
|
|
|
|
|
+ mov basura, 4
|
|
|
|
|
+ sub basura, col_faltan
|
|
|
|
|
+ mov rax, PIXEL_SIZE
|
|
|
|
|
+ mul basura;rdx?
|
|
|
|
|
+ ;shift (4-faltantes) bytes
|
|
|
|
|
+ psrldq xmm2, basura ;ok, borre los que no queria
|
|
|
|
|
+
|
|
|
|
|
+ ;desempaqueto cada pixel a un registro (cada elem como dword)
|
|
|
|
|
+ punpcklbw xmm2, xmm3
|
|
|
|
|
+ punpckhbw xmm2, xmm4
|
|
|
|
|
+
|
|
|
|
|
+ punpcklwd xmm3, xmm5
|
|
|
|
|
+ punpckhwd xmm3, xmm6
|
|
|
|
|
+ punpcklwd xmm4, xmm7
|
|
|
|
|
+ punpckhwd xmm4, xmm8
|
|
|
|
|
+
|
|
|
|
|
+ ;cargo 1 elem de matriz como single
|
|
|
|
|
+ ;FIXME esto carga 4
|
|
|
|
|
+ movdqu xmm9, [matriz]
|
|
|
|
|
+ ;lo clono con mascara a los 4 elem del xmm
|
|
|
|
|
+
|
|
|
|
|
+ ;multiplico cada pixel por su coeficiente de la matriz(float)
|
|
|
|
|
+ mulps xmm5, xmm9
|
|
|
|
|
+ mulps xmm6, xmm9
|
|
|
|
|
+ mulps xmm7, xmm9
|
|
|
|
|
+ mulps xmm8, xmm9
|
|
|
|
|
+
|
|
|
|
|
+ ;acumulo
|
|
|
|
|
+ addps xmm10, xmm5
|
|
|
|
|
+ addps xmm10, xmm6
|
|
|
|
|
+ addps xmm10, xmm7
|
|
|
|
|
+ addps xmm10, xmm8
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ ;actualizo cuantos faltan
|
|
|
|
|
+ sub col_faltan, 4*PIXEL_SIZE
|
|
|
|
|
+ cmp col_faltan, 4
|
|
|
|
|
+ jg .loopFila
|
|
|
|
|
+ cmp col_faltan, 0
|
|
|
|
|
+ jle .finFilaInterna
|
|
|
|
|
+
|
|
|
|
|
+ ;me faltan entre 0 y 4 pixeles, retrocedo suficiente para que me falten 4 exactos
|
|
|
|
|
+ lea src, [src-(4-col_faltan)]
|
|
|
|
|
+ jmp .loopFila
|
|
|
|
|
+
|
|
|
|
|
+ .finFilaInterna:
|
|
|
|
|
+ dec filas_faltan
|
|
|
|
|
+ cmp filas_faltan, 0
|
|
|
|
|
+ je .sumar
|
|
|
|
|
+
|
|
|
|
|
+ jmp .loopInterno
|
|
|
|
|
+
|
|
|
|
|
+ ;avanzo ancho img - (2k+1 pix)
|
|
|
|
|
+ ;faltan >0 filas? jmp .loopInterno
|
|
|
|
|
+
|
|
|
|
|
+.sumar:
|
|
|
.write:
|
|
.write:
|
|
|
- movd [dst], xmm1 ; Escribo en el destino
|
|
|
|
|
|
|
+ movdqu [dst], xmm10 ; Escribo en el destino
|
|
|
.endLoop:
|
|
.endLoop:
|
|
|
add src, PIXEL_SIZE ; Incremento 4 pixeles
|
|
add src, PIXEL_SIZE ; Incremento 4 pixeles
|
|
|
add dst, PIXEL_SIZE
|
|
add dst, PIXEL_SIZE
|
|
@@ -93,6 +161,9 @@ blur_asm:
|
|
|
.fin:
|
|
.fin:
|
|
|
pop r15
|
|
pop r15
|
|
|
pop r14
|
|
pop r14
|
|
|
|
|
+ pop r13
|
|
|
|
|
+ pop r12
|
|
|
|
|
+ pop r11
|
|
|
pop r10
|
|
pop r10
|
|
|
pop r9
|
|
pop r9
|
|
|
pop rbp
|
|
pop rbp
|