-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
79 lines (73 loc) · 1.08 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
using namespace std;
int __stdcall getRealRootsCount(int a, int b, int c)
{
int res;
__asm {
mov ebx, 4
imul ebx, a
imul ebx, c
neg ebx
mov eax, b
imul eax, b
add eax, ebx
cmp eax, 0
jz zero
jl less
mov res, 2
jmp the_end
zero:
mov res, 1
jmp the_end
less:
mov res, 0
the_end:
}
return res;
}
int __stdcall sumArray(int* a, int n)
{
int res;
__asm {
xor eax,eax
mov esi, a
mov ecx, n
cycle:
add eax, [esi]
add esi, 4
loop cycle
mov res, eax
}
return res;
}
int main()
{
int a, b, c, res;
cout << "Enter A, B, C: ";
cin >> a >> b >> c;
__asm {
push c
push b
push a
call getRealRootsCount
mov res, eax
}
cout << res << endl;
int n;
cout << "Enter elements count: ";
cin >> n;
int* arr = new int[n];
//int arr[3] = {1,2,3};
cout << "Enter elements: ";
for (int i = 0; i < n; i++)
cin >> arr[i];
__asm {
push n
push arr
call sumArray
mov res, eax
}
cout << res << endl;
cout << endl;
return 0;
}