Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. .section .text
  2. .global count_bits_zero
  3. .global vec_count_bits_zero
  4.  
  5. count_bits_zero:
  6. # prologue
  7. pushl %ebp # save previous stack frame pointer
  8. movl %esp, %ebp # the stack frame pointer for sum function
  9.  
  10. movl 8(%ebp) , %edx # %edx = num
  11. movl $32 , %ecx # numero de bits em 4 bytes
  12. movl $32 , %eax # contador de 0s
  13.  
  14. looper:
  15. shr %edx
  16. sbb $0 , %eax
  17. loop looper
  18.  
  19. # epilogue
  20. movl %ebp, %esp # restore the previous stack pointer ("clear") the stack)
  21. popl %ebp # restore the previous stack frame pointer
  22. ret
  23.  
  24.  
  25. vec_count_bits_zero:
  26. # prologue
  27. pushl %ebp # save previous stack frame pointer
  28. movl %esp, %ebp # the stack frame pointer for sum function
  29.  
  30. movl 8(%ebp) , %ebx # %ebx = vec
  31. movl 12(%ebp) , %ecx # %ecx = num
  32. movl $0 , %esi # %esi = contador
  33. movl (%ebx) , %edi # %edi = vec[0]
  34.  
  35. vec_looper:
  36.  
  37. pushl %ebx
  38. pushl %ecx
  39. pushl %edi
  40. call count_bits_zero
  41. addl %eax , %esi
  42. popl %ebx
  43. popl %ecx
  44. popl %ebx
  45.  
  46. addl $4 , %ebx
  47. movl (%ebx) , %edi
  48.  
  49. loop vec_looper
  50.  
  51. movl %esi , %eax
  52.  
  53. # epilogue
  54. movl %ebp, %esp # restore the previous stack pointer ("clear") the stack)
  55. popl %ebp # restore the previous stack frame pointer
  56. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement