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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
| ; Template for console application
.586
.MODEL flat, stdcall
OPTION CASEMAP:NONE
Include kernel32.inc
Include masm32.inc
IncludeLib kernel32.lib
IncludeLib masm32.lib
.CONST
MsgExit DB "Press Enter to Exit",0AH,0DH,0
MsgInput DB "Enter 8 words of 5 characters each",0AH,0DH,0
image_vowels DB "AaEeIiOoUuYy", 0ah,0dh,0
image_wordbreaker DB " ",0ah,0dh,0
MsgMainCycle DB "in main cycle", 0ah,0dh,0
MsgTotalVowels DB 'Total vowels - ',0,0,0
MsgInWord DB 'in word ',0,0,0
MsgSpace DB " - ", 0,0,0
MsgVowels DB " vowels",10,13,0
MsgTooManySeparate DB "Too many words", 0ah,0dh,0
max_iterator_main_cycle dw 48
max_iterator_inner_cycle dw 12
max_word_counter dw 8
.DATA
iterator_main_cycle dw 0
iterator_inner_cycle dw 0
word_counter dw 0
vowels_count_arr dw 8 dup (0)
reserv DB 10 DUP(' '),0ah,0dh,0
MsgCountTotalVowels DWORD 0
line_feed DB 10,13,0
;source_str db "aAawa aaAtt dsAyss stttk eiouy EIOUY tttwt yyyyA"
counter_total_vowers dw 0
counter_vowers dw 0
.DATA?
inbuf DB 100 DUP (?)
source_str DB 100 DUP(?)
.CODE
Start:
Invoke StdOut,ADDR MsgInput
Invoke StdIn,ADDR source_str,LengthOf source_str
XOR EAX,EAX
XOR ebx,ebx
XOR ecx,ecx
main_cycle:
XOR edx,edx
lea esi, source_str
mov iterator_inner_cycle,0
mov al,[esi][ecx]
lea edi , image_wordbreaker
cmp al, [edi]
je is_new_word
lea edi , image_vowels
inner_cycle:
cmp al, [edi][edx]
jne next_vowels
inc counter_total_vowers
inc counter_vowers
xor esi,esi
mov si,word_counter
mov dx,counter_vowers
mov vowels_count_arr[esi*2],dx
xor edx,edx
jmp next_char
next_vowels:
inc iterator_inner_cycle
mov dx,iterator_inner_cycle
cmp dx, max_iterator_inner_cycle
jne inner_cycle
next_char:
inc iterator_main_cycle
mov cx,iterator_main_cycle
cmp cx, max_iterator_main_cycle
je print_result
jmp main_cycle
is_new_word:
inc word_counter
mov counter_vowers, 0
mov bx,word_counter
cmp bx,max_word_counter
jg is_too_many_breakwords
jmp next_char
is_too_many_breakwords:
XOR EAX,EAX
Invoke StdOut,ADDR MsgTooManySeparate
jmp print_exit
print_result:
XOR EAX,EAX
Invoke StdOut,addr MsgTotalVowels
XOR EAX,EAX
mov ax,counter_total_vowers
mov MsgCountTotalVowels, eax
XOR EAX,EAX
Invoke dwtoa,MsgCountTotalVowels , ADDR reserv
Invoke StdOut,addr reserv
Invoke StdOut,addr line_feed
mov word_counter,0
start_cycle_print:
XOR EAX,EAX
Invoke StdOut,addr MsgInWord
XOR EAX,EAX
mov ax,word_counter
add ax,1
mov MsgCountTotalVowels, eax
XOR EAX,EAX
Invoke dwtoa,MsgCountTotalVowels , ADDR reserv
Invoke StdOut,addr reserv
Invoke StdOut,addr MsgSpace
xor esi,esi
XOR EAX,EAX
mov si,word_counter
mov ax,vowels_count_arr[esi*2]
mov MsgCountTotalVowels, eax
XOR EAX,EAX
Invoke dwtoa,MsgCountTotalVowels , ADDR reserv
Invoke StdOut,addr reserv
Invoke StdOut,addr MsgVowels
;Invoke StdOut,addr line_feed
inc word_counter
mov cx,word_counter
cmp cx, max_word_counter
je print_exit
jmp start_cycle_print
print_exit:
XOR EAX,EAX
Invoke StdOut,ADDR MsgExit
Invoke StdIn,ADDR inbuf,LengthOf inbuf
Invoke ExitProcess,0
End Start |