Guest User

tpc2.s

a guest
Apr 28th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. .text
  2. .globl charHistogram
  3.  
  4. charHistogram:
  5. pushl %ebp
  6. movl %esp, %ebp
  7.  
  8. movl 8(%ebp), %edx #str[]
  9. movl 12(%ebp), %eax #hist[26]
  10. movl $0, %ecx #i = 0
  11.  
  12. ini: #ciclo para inicializar o vector a 0
  13. cmpl $26, %ecx
  14. je next
  15. movl $0, (%eax, %ecx, 4)
  16. incl %ecx
  17. jmp ini
  18.  
  19. next:
  20. movl $0, %ecx #i = 0
  21.  
  22. first:
  23. cmpb $0, (%edx) #*str != '\0'
  24. je end
  25.  
  26. second:
  27. cmpl $26, %ecx #i < 26
  28. je cont
  29.  
  30. if:
  31. addb $'a, %cl #i = i+'a'
  32. cmpb %cl, (%edx) #*str == 'a'+i
  33. je op
  34. subb $'a, %cl #restaurar valor %ecx
  35. addb $'A, %cl #i = i+'A'
  36. cmpb %cl, (%edx) #*str == 'A'+i
  37. jne after_if
  38. subb $'A, %cl #restaurar valor %ecx
  39. addl $4, (%eax, %ecx, 4) #hist[i]++
  40.  
  41. after_if:
  42. incl %ecx #i++
  43. jmp second
  44.  
  45. op:
  46. subb $'a, %cl #restaurar valor %ecx
  47. addl $4, (%eax, %ecx, 4) #hist[i]++
  48. jmp after_if
  49.  
  50. cont:
  51. movl $0, %ecx #i = 0
  52. addb $1, (%edx) #*str++
  53. jmp first
  54.  
  55. end:
  56. movl %ebp, %esp
  57. popl %ebp
  58. ret
Advertisement
Add Comment
Please, Sign In to add comment