Advertisement
Guest User

Untitled

a guest
May 26th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1.  
  2. #include "pch.h"
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. struct vect
  7. {
  8. int x;
  9. int y;
  10. };
  11.  
  12. int add(int, int);
  13. int sub(int, int);
  14. int prov(int, int);
  15. vect addvect(vect, vect);
  16.  
  17. vect first;
  18. vect second;
  19.  
  20. int SUM;
  21. int SUB;
  22. int promsum;
  23.  
  24. int main()
  25. {
  26. setlocale(LC_ALL, "rus");
  27. SUM = 0;
  28. promsum = 0;
  29. SUB = 0;
  30. first.x = 2;
  31. first.y = 2;
  32. second.x = 10;
  33. second.y = 16;
  34.  
  35. __asm //Инициализация
  36. {
  37.  
  38. mov eax, 8;
  39. mov ebx, 12;
  40. mov ecx, 30;
  41. /*mov edx, 0;*/
  42. /*add sum, eax;
  43. add sum, ebx;
  44. add sum, ecx;
  45. mov edx, sum;*/
  46. }
  47.  
  48. __asm
  49. {
  50. add SUM, eax;
  51. add SUM, ebx;
  52. add SUM, ecx;
  53. mov edx, SUM;
  54. }
  55. cout << "Сумма чисел, находящихся в регистрах равна: " << SUM << endl;
  56.  
  57. __asm
  58. {
  59. add promsum, eax;
  60. add promsum, ebx;
  61. mov edx, 0;
  62. sub promsum, ecx;
  63. mov edx, promsum;
  64. }
  65. cout << "Разность суммы чисел, находящихся в регистрах EAX, EBX, и числа из регистра ECX равна: " << promsum << endl;
  66. vect privet;
  67. privet = addvect(first, second);
  68. cout << privet.x << " " << privet.y;
  69. }
  70.  
  71. int add(int a, int b)
  72. {
  73. return a + b;
  74. }
  75.  
  76. vect addvect(vect a,vect b)
  77. {
  78. vect c;
  79. c.x = a.x + b.x;
  80. c.y = a.y + b.y;
  81. return c;
  82. }
  83.  
  84. int sub(int a, int b)
  85. {
  86. return a - b;
  87. }
  88.  
  89. int prov(int a, int b)
  90. {
  91. int res;
  92. if (a > b) res = sub(a, b);
  93. else res = add(a, b);
  94. return res;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement