Guest User

remove_spaces.S

a guest
Jan 11th, 2021
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .intel_syntax noprefix
  2. .global remove_spaces_asm16
  3.  
  4. .section .mydata, "a"
  5.     maps:
  6.         .incbin "map.bin"
  7.     shifts = maps + 0x10000*16
  8.     spaces16:
  9.         .fill 16, 1, 0x20
  10.  
  11. .text
  12.     remove_spaces_asm16:
  13.         // char* remove_spaces_asm16(char *in, char *out, unsigned int count);
  14.         // rdi, rsi, rdx
  15.        
  16.         vmovdqu xmm2, [spaces16]
  17.        
  18.         1:
  19.             vmovdqu     xmm0, [rdi]
  20.             vpcmpeqb    xmm1, xmm2, xmm0
  21.             vpmovmskb   rax, xmm1
  22.             movzx       ecx, byte ptr [shifts + rax]
  23.             shl         eax, 4
  24.             vpshufb     xmm0, xmm0, [maps + rax]
  25.             vmovdqu     [rsi], xmm0
  26.             add         rdi, 16
  27.             add         rsi, rcx
  28.             sub         rdx, 16
  29.             jne 1b
  30.        
  31.         mov rax, rsi
  32.        
  33.         ret
  34.  
Advertisement
Add Comment
Please, Sign In to add comment