Advertisement
MichaelPetch

SO78838831 - ver2

Aug 6th, 2024
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. Include irvine32.inc
  2.  
  3. ;irvine32.inc already uses this directive for us:
  4. ; .model flat, STDCALL
  5.  
  6. .data
  7. result DWORD ?
  8.  
  9. .code
  10.  
  11. add_func PROC C a:SDWORD, b:SDWORD
  12. ; SDWORD type is a signed 32-bit value
  13.  
  14. ; When parameters are specifiec with PROC push ebp and mov ebp, esp
  15. ; prologue are done automatically
  16.  
  17. ; Get the arguments
  18. mov eax, a
  19. mov ecx, b
  20.  
  21. ; Add a and b
  22. add eax, ecx
  23.  
  24. ; Store the result in a variable
  25. mov result, eax
  26.  
  27. call WriteInt
  28.  
  29. exit_function:
  30.  
  31. ; Return the result in EAX
  32. mov eax, result
  33. ; When a RET instruction is found by MASM inside a PROC
  34. ; defined function proper epilogue code
  35. ; will be emitted (restoring ESP from EBP etc). If STDCALL
  36. ; calling convention is declared with PROC the RET will be
  37. ; modified by MASM so that it removes the specified number of
  38. ; byte from the stack based on the arguments defined by PROC.
  39. ; With CDECL this will just be a RET instruction.
  40. ret
  41.  
  42. add_func ENDP
  43.  
  44. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement