Advertisement
Coriic

Untitled

Jun 25th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. .data
  2. occurences:
  3. .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  4. .text
  5. .type check_tab, @function
  6. .global check_tab
  7.  
  8. #tab->n->max
  9. check_tab:
  10. XOR %rbx, %rbx
  11. XOR %rax, %rax
  12. XOR %r8, %r8
  13. XOR %r9, %r9
  14. XOR %rcx, %rcx
  15. MOV $0, %ecx
  16. clear:
  17. MOV $0, occurences(, %ecx, 4)
  18. INC %ecx
  19. CMP $64, %ecx
  20. JNE clear
  21. XOR %ecx, %ecx
  22. MOV %rdi, %r9
  23. loop:
  24. CMP $0, %rsi
  25. JE afterLoop
  26. CMPB $0, (%rdi)
  27. JL afterHashing
  28. CMPB $63, (%rdi)
  29. JG afterHashing
  30. MOV (%rdi), %eax
  31. MOV occurences(, %eax, 4), %ebx
  32. INC %ebx
  33. MOV %ebx, occurences(, %eax, 4)
  34. afterHashing:
  35. ADD $4, %rdi
  36. DEC %rsi
  37. JMP loop
  38. afterLoop:
  39. MOV $63, %ecx
  40. XOR %rax, %rax
  41. XOR %rbx, %rbx
  42. MOV $0, %rbx
  43. loop2:
  44. XOR %r8, %r8
  45. MOV occurences(, %ecx, 4), %r8
  46. CMP %r8, %rbx
  47. JB swapMax
  48. afterSwap:
  49. SHL $1, %rax
  50. CMP $0, %r8
  51. JE noOccurences
  52. ADD $1, %rax
  53. afterModifing:
  54. DEC %ecx
  55. CMP $0, %ecx
  56. JGE loop2
  57. MOV %rbx, (%rdx)
  58. MOV %r9, %rdi
  59. RET
  60.  
  61. swapMax:
  62. MOV %r8, %rbx
  63. JMP afterSwap
  64.  
  65. noOccurences:
  66. ADD $0, %rax
  67. JMP afterModifing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement