Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- struct vect
- {
- int x;
- int y;
- };
- int add(int, int);
- int sub(int, int);
- int prov(int, int);
- vect addvect(vect, vect);
- vect first;
- vect second;
- int SUM;
- int SUB;
- int promsum;
- int main()
- {
- setlocale(LC_ALL, "rus");
- SUM = 0;
- promsum = 0;
- SUB = 0;
- first.x = 2;
- first.y = 2;
- second.x = 10;
- second.y = 16;
- __asm //Инициализация
- {
- mov eax, 8;
- mov ebx, 12;
- mov ecx, 30;
- /*mov edx, 0;*/
- /*add sum, eax;
- add sum, ebx;
- add sum, ecx;
- mov edx, sum;*/
- }
- __asm
- {
- add SUM, eax;
- add SUM, ebx;
- add SUM, ecx;
- mov edx, SUM;
- }
- cout << "Сумма чисел, находящихся в регистрах равна: " << SUM << endl;
- __asm
- {
- add promsum, eax;
- add promsum, ebx;
- mov edx, 0;
- sub promsum, ecx;
- mov edx, promsum;
- }
- cout << "Разность суммы чисел, находящихся в регистрах EAX, EBX, и числа из регистра ECX равна: " << promsum << endl;
- vect privet;
- privet = addvect(first, second);
- cout << privet.x << " " << privet.y;
- }
- int add(int a, int b)
- {
- return a + b;
- }
- vect addvect(vect a,vect b)
- {
- vect c;
- c.x = a.x + b.x;
- c.y = a.y + b.y;
- return c;
- }
- int sub(int a, int b)
- {
- return a - b;
- }
- int prov(int a, int b)
- {
- int res;
- if (a > b) res = sub(a, b);
- else res = add(a, b);
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement