Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global sort64
- sort64: start
- pushaq
- mov rax, rdi ; float* x
- mov rbx, rsi ; int n
- call sort
- popaq
- stop
- ; --------------------------------------------------
- ; Inserire qui il proprio algoritmo di ordinamento
- ; --------------------------------------------------
- ; rax = vector start address
- ; rbx = vector length
- ; --------------------------------------------------
- sort:
- cmp rbx, 1
- jle endl
- mov rdi, rbx ;contatore ciclo esterno
- sub rdi, 4
- mov rcx, 0 ;se 1 ci sono stati scambi, se 0 no
- ciclo_esterno:
- mov rsi, 0 ;contatore ciclo interno
- ciclo_interno:
- vmovups ymm0, [rax+rsi*4]
- vmovaps ymm2, ymm0
- vshufps ymm2, ymm2, 10010000b
- vcmpleps ymm2, ymm0
- vmovmskps rdx, ymm2
- cmp rdx, 255
- je incremento
- mov rcx, 1
- vmovaps ymm1, ymm0
- vshufps ymm1, ymm1, 11101110b
- vmovaps ymm2, ymm0
- vminps ymm0, ymm1
- vmaxps ymm1, ymm2
- vshufps ymm1, ymm1, 11100001b
- vmovaps ymm2, ymm0
- vminps ymm0, ymm1
- vmaxps ymm1, ymm2
- vmovaps ymm2, ymm0
- vshufps ymm2, ymm2, 11100001b ; confronto la coppia dei minimi
- vcmpltps ymm2, ymm0
- vmovmskps edx, xmm2
- cmp edx, 2
- je cmp_max
- vshufps ymm0, ymm0, 11100001b ; non sono ordinati all'interno quindi scambio
- cmp_max:
- vmovaps ymm2, ymm1
- vshufps ymm2, ymm2, 11100001b ; confronto la coppia dei minimi
- vcmpltps ymm2, ymm1
- vmovmskps edx, xmm2
- cmp edx, 2
- je unisci
- vshufps ymm1, ymm1, 11100001b ; non sono ordinati all'interno quindi scambio
- unisci:
- vshufps ymm0,ymm1, 01000100b
- vmovups [rax+rsi*4], xmm0
- incremento:
- inc rsi
- cmp rsi, rdi
- jg aggiorna_rdi
- jmp ciclo_interno
- aggiorna_rdi:
- cmp rcx, 0
- je endl
- dec rdi
- cmp rdi, 0
- jl endl
- jmp ciclo_esterno
- endl: ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement