Advertisement
venik2405

lab6_2_max

May 24th, 2021
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. const int ARR_SIZE = 3;
  5. int arr[ARR_SIZE];
  6. int res_c = 1;
  7. int res_asm = 1;
  8. cout << "This program finds mul of positive elements in array of size 3" << endl;
  9. for (int i = 0; i < ARR_SIZE; i++) {
  10. printf("Input element %d: ", i + 1);
  11. cin >> arr[i];
  12. }
  13. for (int i = 0; i < ARR_SIZE; i++) {
  14. if (arr[i] > 0)
  15. res_c = res_c * arr[i];
  16. }
  17. __asm {
  18. lea esi, arr
  19. mov ecx, ARR_SIZE
  20. xor eax, eax
  21. mov eax, 1h
  22. next_ :
  23. mov ebx, [esi]
  24. cmp ebx, 0
  25. jle skip_
  26. imul ebx
  27. skip_ :
  28. add esi, 4
  29. loop next_
  30. mov res_asm, eax
  31. }
  32. printf("Result in c++: %d\nResult in asm: %d\n", res_c, res_asm);
  33. system("pause");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement