-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc4.c
91 lines (66 loc) · 1.56 KB
/
func4.c
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
80
81
82
83
84
85
86
87
88
89
90
91
void Func4(int* pArray, int sizeArr, int* run, int* freq) {
int greatestRun = 0;
int greatestFreq = 0;
int necSize = sizeArr;
_asm {
push ebx
mov ecx, sizeArr //want to compare each element against entire array
mov esi, pArray //get address of array into esi
runFind:
mov edx, [esi] //get element at address of esi into edx
push ecx //comparing against array, saving for outer loop
mov ecx, necSize //each element in, you need to iterate one less
mov edi, esi //get current index of array
compare:
mov ebx, 0 //used to keep track of current streak
mov eax, [edi] //get second for loop's element at index
cmp eax, edx //compare element against second for loop's
je run
//if not equal, run is broken
mov ecx, 0 //want to stop looping
cmp ebx, greatestFreq //see if I set a new record
jl run
//did set a new record, want to record stats
mov greatestFreq, ebx
mov greatestRun, edx
run:
inc ebx
add edi, 4
loop compare
dec necSize
pop ecx
add esi, 4
loop runFind
pop ebx
}
}
/* //int Func3(int* pArray, int sizeArr){
_asm
lea esi, pArray
mov eax, [esi]
add pArray, 4
mov ecx, sizeArr
dec ecx //first element is initial largest
greatestLoop:
cmp eax, [esi]
jg skip
mov eax, [esi]
add pArray, 4
skip:
loop greatestLoop
}
.586
.model flat, c
.stack
.data
.code
func1 proc
mov ecx, sizeArr
mov eax, 0
arrAddLoop:
add eax, [pArray]
add pArray, 4
loop arrAddLoop
func1 endp
end
*/