Advertisement
venik2405

lab6_3

May 24th, 2021
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. cout << "This program finds amount of elements that are much than a number" << endl;
  5. cout << "Input array's size: ";
  6. int arr_size;
  7. cin >> arr_size;
  8. int* arr = (int*)malloc(arr_size * sizeof(int));
  9. for (int i = 0; i < arr_size; i++) {
  10. printf("Input element %d: ", i + 1);
  11. cin >> arr[i];
  12. }
  13. cout << "Input number: ";
  14. int number_check;
  15. cin >> number_check;
  16. int res_c = 0;
  17. int res_asm = 0;
  18. for (int i = 0; i < arr_size; i++) {
  19. if (arr[i] > number_check)
  20. res_c = res_c + arr[i];
  21. }
  22. __asm {
  23. mov esi, arr
  24. mov ecx, arr_size
  25. mov edx, number_check
  26. xor eax, eax
  27. next_ :
  28. mov ebx, [esi]
  29. cmp ebx, ed
  30. jbe skip_
  31. add eax, ebx
  32. skip_ :
  33. add esi, 4
  34. loop next_
  35. mov res_asm, eax
  36. }
  37. printf("Result in c++: %d\nResult in asm: %d\n", res_c, res_asm);
  38. system("pause");
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement