Advertisement
venik2405

lab6_1_ass

May 16th, 2021
3,334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int a, b, c, d, res_c, res_asm = 0;
  7.     cout << "This program calculates ((b + 4) * a + d) / (c * 3))" << endl;
  8.     cout << "Input only 16bit numbers!" << endl;
  9.     cout << "Input a: ";
  10.     cin >> a;                                       // 4 2 3 3
  11.     cout << "Input b: ";
  12.     cin >> b;
  13.     cout << "Input c: ";
  14.     cin >> c;
  15.     cout << "Input d: ";
  16.     cin >> d;
  17.     res_c = (b + 4) * a + d;
  18.     res_c /= c * 3;
  19.     __asm {
  20.         mov eax, b
  21.         add eax, 4
  22.         mov ebx, a
  23.         imul ebx
  24.         mov ebx, d
  25.         add eax, ebx
  26.         mov ebx, eax
  27.         mov eax, c
  28.         mov ecx, 3
  29.         mul ecx
  30.         mov ecx, eax
  31.         mov eax, ebx
  32.         idiv ecx
  33.         mov res_asm, eax
  34.     }
  35.     printf("Result c++: %d\nResult asm: %d\n", res_c, res_asm);
  36.     system("pause");
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement