Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .section .text
- .global count_bits_zero
- .global vec_count_bits_zero
- count_bits_zero:
- # prologue
- pushl %ebp # save previous stack frame pointer
- movl %esp, %ebp # the stack frame pointer for sum function
- movl 8(%ebp) , %edx # %edx = num
- movl $32 , %ecx # numero de bits em 4 bytes
- movl $32 , %eax # contador de 0s
- looper:
- shr %edx
- sbb $0 , %eax
- loop looper
- # epilogue
- movl %ebp, %esp # restore the previous stack pointer ("clear") the stack)
- popl %ebp # restore the previous stack frame pointer
- ret
- vec_count_bits_zero:
- # prologue
- pushl %ebp # save previous stack frame pointer
- movl %esp, %ebp # the stack frame pointer for sum function
- movl 8(%ebp) , %ebx # %ebx = vec
- movl 12(%ebp) , %ecx # %ecx = num
- movl $0 , %esi # %esi = contador
- movl (%ebx) , %edi # %edi = vec[0]
- vec_looper:
- pushl %ebx
- pushl %ecx
- pushl %edi
- call count_bits_zero
- addl %eax , %esi
- popl %ebx
- popl %ecx
- popl %ebx
- addl $4 , %ebx
- movl (%ebx) , %edi
- loop vec_looper
- movl %esi , %eax
- # epilogue
- movl %ebp, %esp # restore the previous stack pointer ("clear") the stack)
- popl %ebp # restore the previous stack frame pointer
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement