Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .section .data
- .global ptrgrades
- .global num
- .global ptrfreq
- .global freqs
- .section .text
- .global frequencies
- frequencies:
- # prologue
- pushl %ebp # save previous stack frame pointer
- movl %esp, %ebp # the stack frame pointer for sum function
- movl ptrfreq, %eax
- movl ptrgrades, %edx
- movl $0, %ecx # 0 to 20 incrementador
- pushl %ebx
- movl $0, %ebx
- movl $0, %esi
- mainLoop:
- cmpl $20, %ecx
- je fim
- jmp innerLoop
- innerLoop:
- cmpl num, %ebx
- je prepareNextLoop
- cmpl %ecx, (%edx)
- je foundGrade
- incl %edx
- incl %ebx
- jmp innerLoop
- foundGrade:
- incl %esi
- incl %edx
- incl %ebx
- jmp innerLoop
- prepareNextLoop:
- movl %esi, (%eax)
- incl %eax
- incl %ecx
- jmp mainLoop
- fim:
- popl %ebx
- # epilogue
- movl %ebp, %esp # restore the previous stack pointer ("clear" the stack)
- popl %ebp # restore the previous stack frame pointer
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement