|
@@ -2,10 +2,19 @@ default rel
|
|
|
global _blur_asm
|
|
global _blur_asm
|
|
|
global blur_asm
|
|
global blur_asm
|
|
|
|
|
|
|
|
|
|
+; Alias para no volverme loco con los registros
|
|
|
|
|
+%define src rdi
|
|
|
|
|
+%define dst rsi
|
|
|
|
|
+%define cols rdx
|
|
|
|
|
+%define filas rcx
|
|
|
|
|
+%define sigma xmm0
|
|
|
|
|
+%define radius r8
|
|
|
|
|
|
|
|
-section .data
|
|
|
|
|
-
|
|
|
|
|
|
|
+; Algunos defines ultiles
|
|
|
|
|
+%define PIXEL_SIZE 4
|
|
|
|
|
|
|
|
|
|
+; Mascaras y esas cosas
|
|
|
|
|
+section .data
|
|
|
|
|
|
|
|
section .text
|
|
section .text
|
|
|
;void blur_asm (
|
|
;void blur_asm (
|
|
@@ -18,6 +27,75 @@ section .text
|
|
|
|
|
|
|
|
_blur_asm:
|
|
_blur_asm:
|
|
|
blur_asm:
|
|
blur_asm:
|
|
|
|
|
+ push rbp
|
|
|
|
|
+ mov rbp, rsp ; Stack frame
|
|
|
|
|
+ push r9
|
|
|
|
|
+ push r10
|
|
|
|
|
+ push r11
|
|
|
|
|
+
|
|
|
|
|
+.init:
|
|
|
|
|
+ mov r9, rdx ;salvo rdx por los mul
|
|
|
|
|
+ mov rax, PIXEL_SIZE
|
|
|
|
|
+ mul cols
|
|
|
|
|
+ mul radius
|
|
|
|
|
+ ;rax ahora es cols*pix_size*radius
|
|
|
|
|
+ add src, rax ; Avanzo el radius filas (col*pix_size)
|
|
|
|
|
+ add dst, rax ; idem
|
|
|
|
|
+
|
|
|
|
|
+ mov rax, PIXEL_SIZE
|
|
|
|
|
+ mul radius ;rax ahora es radius pixeles
|
|
|
|
|
+
|
|
|
|
|
+ add src, rax ;avanzo radius pixeles (borde)
|
|
|
|
|
+ add dst, rax ;idem
|
|
|
|
|
+
|
|
|
|
|
+ mov cols, r9 ;recupero cols por el mul
|
|
|
|
|
+ sub filas, radius ;acomodo filas para ignorar los bordes
|
|
|
|
|
+ sub filas, radius ;acomodo filas para ignorar los bordes
|
|
|
|
|
+
|
|
|
|
|
+ sub cols, rax ;acomodo cols para ignorar los bordes
|
|
|
|
|
+
|
|
|
|
|
+ mov rax,PIXEL_SIZE
|
|
|
|
|
+ mul cols
|
|
|
|
|
+ mov cols, rax ;cols:=cols*pix_size
|
|
|
|
|
+ xor r9,r9
|
|
|
|
|
+ xor r10,r10
|
|
|
|
|
+.loop:
|
|
|
|
|
+ cmp cols, r9 ; Comparo tamaño con el contador
|
|
|
|
|
+ jl .finFila ; Si ya recorri la imagen voy al final
|
|
|
|
|
+ ;movdqu xmm0, [src] ; Cargo la imagen 1 => xmm0 = |B(P1)|G(P1)|R(P1)|A(P1)|B(P2)|G(P2)|......|
|
|
|
|
|
+ pxor xmm0,xmm0
|
|
|
|
|
+
|
|
|
|
|
+.write:
|
|
|
|
|
+ movdqu [dst], xmm0 ; Escribo en el destino
|
|
|
|
|
+.endLoop:
|
|
|
|
|
+ add src, PIXEL_SIZE * 4 ; Incremento 4 pixeles
|
|
|
|
|
+ add dst, PIXEL_SIZE * 4
|
|
|
|
|
+ add r9, PIXEL_SIZE * 4
|
|
|
|
|
+ jmp .loop
|
|
|
|
|
+
|
|
|
|
|
+.finFila:
|
|
|
|
|
+ inc r10
|
|
|
|
|
+ cmp r10,filas
|
|
|
|
|
+ jge .fin
|
|
|
|
|
+
|
|
|
|
|
+ xor r9,r9
|
|
|
|
|
+
|
|
|
|
|
+ mov r11, rdx ;salvo rdx
|
|
|
|
|
+ mov rax, PIXEL_SIZE
|
|
|
|
|
+ mul radius ;rax ahora es radius pixeles
|
|
|
|
|
+
|
|
|
|
|
+ add src, rax ;agrego radius a la columna inicial
|
|
|
|
|
+ add src, rax ;agrego radius a la columna inicial
|
|
|
|
|
+ add dst, rax
|
|
|
|
|
+ add dst, rax
|
|
|
|
|
+
|
|
|
|
|
+ mov rdx, r11 ;recupero rdx
|
|
|
|
|
|
|
|
|
|
+ jmp .loop
|
|
|
|
|
|
|
|
|
|
+.fin:
|
|
|
|
|
+ pop r11
|
|
|
|
|
+ pop r10
|
|
|
|
|
+ pop r9
|
|
|
|
|
+ pop rbp
|
|
|
ret
|
|
ret
|