-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex4.s
57 lines (48 loc) · 754 Bytes
/
ex4.s
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
#Program for counting substring 'ad' in a given string
.intel_syntax noprefix
.text
.globl main
main:
mov eax, offset messg
push eax
call policz
add esp, 4
push eax
mov eax, offset printf_arg1
push eax
call printf
add esp, 8
exit:
mov eax, 0
ret
policz:
push ebx
push ecx
mov ecx, -1
push edx
mov edx, 0
search:
inc ecx
mov eax, [esp+16]
add eax, ecx
mov ebx, [eax+1]
mov eax, [eax]
cmp bl, 0
je finish
cmp al, 'a'
jne search
cmp bl, 'd'
jne search
inc edx
jmp search
finish:
mov eax, edx
pop edx
pop ecx
pop ebx
ret
.data
messg:
.asciz "Przykladow ady tekst zadania"
printf_arg1:
.asciz "%i\n"