YauhenMardan

asm_10.1

May 31st, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. extern "C" int __fastcall sumFast(int, int);
  6. extern "C" int __stdcall sumStd(int, int, int);
  7. extern "C" int __cdecl sumCd(int, int, int);
  8.  
  9. int main() {
  10. int x = 2, a = 4, b = 3;
  11. std::cout <<"a+b= "<< sumFast(a, b)<<std::endl;
  12. std::cout << "a*x+b= " << sumStd(a, b, x) << std::endl;
  13. std::cout << "a*x+b= " << sumCd(a, b, x) << std::endl;
  14. system("pause");
  15. return 0;
  16. }
  17.  
  18. .386
  19.  
  20. PUBLIC @sumFast@8
  21. .model flat
  22. .code
  23. @sumFast@8 proc
  24. mov eax,edx
  25. add eax,ecx
  26. ret
  27. @sumFast@8 endp
  28.  
  29.  
  30. PUBLIC _sumStd@12
  31. .model flat
  32. .code
  33. _sumStd@12 proc
  34. push ebp
  35. mov ebp,esp
  36. mov eax, dword ptr [ebp+16]
  37. mov ebx, dword ptr [ebp+12]
  38. mov ecx, dword ptr [ebp+8]
  39. imul ecx
  40. add eax,ebx
  41. pop ebp
  42. ret 12
  43. _sumStd@12 endp
  44.  
  45. PUBLIC _sumCd
  46. .model flat
  47. .code
  48. _sumCd proc
  49. push ebp
  50. mov ebp,esp
  51. mov eax, dword ptr [ebp+16]
  52. mov ebx, dword ptr [ebp+12]
  53. mov ecx, dword ptr [ebp+8]
  54. imul ecx
  55. add eax,ebx
  56. pop ebp
  57. ret
  58. _sumCd endp
  59. end
Advertisement
Add Comment
Please, Sign In to add comment