Advertisement
venik2405

lab6_2ass

May 16th, 2021
2,586
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.     const int ARR_SIZE = 3;
  7.     int arr[ARR_SIZE];
  8.     int res_c = 0;
  9.     int res_asm = 1;
  10.     cout << "This program finds mul of positive elements in array of size 3" << endl;
  11.     for (int i = 0; i < ARR_SIZE; i++) {
  12.         printf("Input element %d: ", i + 1);
  13.         cin >> arr[i];
  14.     }
  15.     for (int i = 0; i < ARR_SIZE; i++) {
  16.         if (arr[i] < 0)
  17.             res_c ++;
  18.     }
  19.     __asm {
  20.         lea esi, arr
  21.         mov ecx, ARR_SIZE
  22.         xor eax, eax
  23.         mov eax, 0h
  24.         next_ :
  25.         mov ebx, [esi]
  26.             cmp ebx, 0
  27.             jge skip_
  28.             add eax, 1
  29.             skip_ :
  30.                 add esi, 4
  31.                 loop next_
  32.             mov res_asm, eax
  33.     }
  34.     printf("Result in c++: %d\nResult in asm: %d\n", res_c, res_asm);
  35.     system("pause");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement