Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. .macro division number
  2. mov $0, %ecx
  3.  
  4. loop_getremainders:
  5. mov $0, %edx
  6. mov number, %eax
  7. mov dividers(,%ecx,4), %ebx
  8. div %ebx
  9. mov %edx, remainders(,%ecx,4)
  10. inc %ecx
  11. cmp $5, %ecx
  12. jne loop_getremainders
  13. int $0x80
  14. .endm
  15.  
  16. .section .data
  17. number: .long 158
  18. remainders: .long 0,0,0,0,0
  19. dividers: .long 7,15,31,127,8192
  20. .section .text
  21. .global _start
  22. _start:
  23. division number
  24. mov $1, %eax
  25. mov $0, %ebx
  26. int $0x80
  27.  
  28. xor %eax, %eax # accumulator
  29. movl $5, %edx # counter
  30. loop_shift:
  31. movb shifts(%edx), %cl # the shift amount
  32. movl remainders(, %edx, 4), %ebx # next remainder
  33. shrd %cl, %ebx, %eax # shift in the bits
  34. subl $1, %edx
  35. jnc loop_shift
  36. .data
  37. shifts: .byte 3, 4, 5, 7, 13
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement