DRVTiny

unpcklbw_asm.cr

Aug 5th, 2021
697
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def hexdo (a : UInt32)
  2.   ptr_result=Pointer(UInt8).malloc(8, 10_u8)
  3.   add_this=0x2020202020202020_u64
  4.   puts pointerof(add_this).address
  5.   asm("
  6. movl ($0), %eax
  7. movd %eax, %mm0
  8. shrl $$4, %eax
  9. movd %eax, %mm1
  10. punpcklbw %mm0, %mm1
  11. paddb ($2), %mm1
  12. movq %mm1, ($1)
  13.  " :: "r"(pointerof(a).address),"r"(ptr_result.address),"r"(pointerof(add_this)
  14.   ptr_result
  15. end
  16.  
  17. x=0xA0B1C2D3_u32
  18. sp=Slice.new(hexdo(x), 8)
  19. puts sp.map{|c| c.unsafe_chr }.join
  20.  
RAW Paste Data