Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .section .data
  2. .global ptrgrades
  3. .global num
  4. .global ptrfreq
  5. .global freqs
  6.  
  7. .section .text
  8. .global frequencies
  9.  
  10.     frequencies:
  11.  
  12. # prologue
  13. pushl %ebp # save previous stack frame pointer
  14. movl %esp, %ebp # the stack frame pointer for sum function
  15.  
  16.     movl ptrfreq, %eax
  17.     movl ptrgrades, %edx
  18.     movl $0, %ecx # 0 to 20 incrementador
  19.     pushl %ebx
  20.     movl $0, %ebx
  21.     movl $0, %esi
  22.    
  23.     mainLoop:
  24.     cmpl $20, %ecx
  25.     je fim
  26.     jmp innerLoop
  27.    
  28.         innerLoop:
  29.         cmpl num, %ebx
  30.         je prepareNextLoop
  31.         cmpl %ecx, (%edx)
  32.         je foundGrade
  33.         incl %edx
  34.         incl %ebx
  35.         jmp innerLoop
  36.        
  37.            
  38.             foundGrade:
  39.             incl %esi
  40.             incl %edx
  41.             incl %ebx
  42.             jmp innerLoop
  43.        
  44.        
  45.             prepareNextLoop:
  46.             movl %esi, (%eax)
  47.             incl %eax
  48.             incl %ecx
  49.             jmp mainLoop
  50.  
  51.    
  52.     fim:
  53.     popl %ebx
  54.  
  55. # epilogue
  56. movl %ebp, %esp # restore the previous stack pointer ("clear" the stack)
  57. popl %ebp # restore the previous stack frame pointer
  58.  
  59. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement