Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text
- .globl charHistogram
- charHistogram:
- pushl %ebp
- movl %esp, %ebp
- movl 8(%ebp), %edx #str[]
- movl 12(%ebp), %eax #hist[26]
- movl $0, %ecx #i = 0
- ini: #ciclo para inicializar o vector a 0
- cmpl $26, %ecx
- je next
- movl $0, (%eax, %ecx, 4)
- incl %ecx
- jmp ini
- next:
- movl $0, %ecx #i = 0
- first:
- cmpb $0, (%edx) #*str != '\0'
- je end
- second:
- cmpl $26, %ecx #i < 26
- je cont
- if:
- addb $'a, %cl #i = i+'a'
- cmpb %cl, (%edx) #*str == 'a'+i
- je op
- subb $'a, %cl #restaurar valor %ecx
- addb $'A, %cl #i = i+'A'
- cmpb %cl, (%edx) #*str == 'A'+i
- jne after_if
- subb $'A, %cl #restaurar valor %ecx
- addl $4, (%eax, %ecx, 4) #hist[i]++
- after_if:
- incl %ecx #i++
- jmp second
- op:
- subb $'a, %cl #restaurar valor %ecx
- addl $4, (%eax, %ecx, 4) #hist[i]++
- jmp after_if
- cont:
- movl $0, %ecx #i = 0
- addb $1, (%edx) #*str++
- jmp first
- end:
- movl %ebp, %esp
- popl %ebp
- ret
Advertisement
Add Comment
Please, Sign In to add comment