Coriic

Untitled

Jun 25th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 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 %rdi, %r9
  16. loop:
  17. CMP $0, %rsi
  18. JE afterLoop
  19. CMPB $0, (%rdi)
  20. JL afterHashing
  21. CMPB $63, (%rdi)
  22. JG afterHashing
  23. MOV (%rdi), %eax
  24. MOV occurences(, %eax, 4), %ebx
  25. INC %ebx
  26. MOV %ebx, occurences(, %eax, 4)
  27. afterHashing:
  28. ADD $4, %rdi
  29. DEC %rsi
  30. JMP loop
  31. afterLoop:
  32. MOV $63, %ecx
  33. XOR %rax, %rax
  34. XOR %rbx, %rbx
  35. MOV $0, %rbx
  36. loop2:
  37. XOR %r8, %r8
  38. MOV occurences(, %ecx, 4), %r8
  39. CMP %r8, %rbx
  40. JB swapMax
  41. afterSwap:
  42. SHL $1, %rax
  43. CMP $0, %r8
  44. JE noOccurences
  45. ADD $1, %rax
  46. afterModifing:
  47. DEC %ecx
  48. CMP $0, %ecx
  49. JGE loop2
  50. MOV %rbx, (%rdx)
  51. MOV %r9, %rdi
  52. RET
  53.  
  54. swapMax:
  55. MOV %r8, %rbx
  56. JMP afterSwap
  57.  
  58. noOccurences:
  59. ADD $0, %rax
  60. JMP afterModifing
Add Comment
Please, Sign In to add comment