Advertisement
madopew

6_1

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