Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- const int ARR_SIZE = 3;
- int arr[ARR_SIZE];
- int res_c = 0;
- int res_asm = 1;
- cout << "This program finds mul of positive elements in array of size 3" << endl;
- for (int i = 0; i < ARR_SIZE; i++) {
- printf("Input element %d: ", i + 1);
- cin >> arr[i];
- }
- for (int i = 0; i < ARR_SIZE; i++) {
- if (arr[i] < 0)
- res_c ++;
- }
- __asm {
- lea esi, arr
- mov ecx, ARR_SIZE
- xor eax, eax
- mov eax, 0h
- next_ :
- mov ebx, [esi]
- cmp ebx, 0
- jge skip_
- add eax, 1
- skip_ :
- add esi, 4
- loop next_
- mov res_asm, eax
- }
- printf("Result in c++: %d\nResult in asm: %d\n", res_c, res_asm);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement