Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: None  |  size: 0.89 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. stack figuration
  2. Parameter #N
  3. ...
  4. ...
  5. Parameter 2  
  6. Parameter 1
  7. Return Address
  8. Old %ebp  
  9. Local Variable 1  
  10. Local Variable 2
  11.  
  12.  
  13. I have no idea what `"Old %ebp"` for.
  14.        
  15. +------------------+
  16. +-> |   prev-prev EBP  |
  17. |   +------------------+
  18. |   | function param 2 |
  19. |   +------------------+
  20. |   | function param 1 |
  21. |   +------------------+
  22. |   |  return address  |
  23. |   +------------------+
  24. +---|   previous EBP   | <-- current EBP
  25.     +------------------+
  26.     |   local var 1    |
  27.     +------------------+
  28.        
  29. push ebp           ; save old base pointer.
  30. mov  ebp, esp      ; set new copy.
  31. sub  esp, 16h      ; allocate space for local variables.
  32.        
  33. add  esp, 16h      ; forget about locals.
  34. pop  ebp           ; restore previous value
  35. ret                ; return to calling code.
  36.        
  37. push %ebp ; save old ebp to stack, this will become old ebp
  38.    mov  %esp, %ebp  ; moving current base pointer to epp