Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .586
- .MODEL flat, stdcall
- OPTION CASEMAP:NONE
- Include kernel32.inc
- Include masm32.inc
- IncludeLib kernel32.lib
- IncludeLib masm32.lib
- .CONST
- MsgExit DB 0AH,0DH,"Program end.",0AH,0DH,0
- initial DB "Initial string: ", 0
- result DB "Numbers of strings: ", 0
- .DATA
- cons DB "qwrtpsdfghjklzxcvbnm", 0
- vowels DB "yueioa", 0
- cons_size dword 20
- vowels_size dword 6
- source DB " omm f e q et yt ioe sfjso ", 0
- space DB " ", 0
- endl DB 10, 13, 0
- buf DB 20 DUP (?)
- string DB 200 DUP (?)
- .CODE
- Start:
- ;-âûâîä èçíà÷àëüíîé ñòðîêè--
- Invoke StdOut, ADDR initial
- Invoke StdOut, ADDR source
- Invoke StdOut, ADDR endl
- ;---------------------------
- Invoke StdOut, ADDR result
- ;--ÂÛ×ÈÑËÅÍÈÅ ÄËÈÍÛ ÑÒÐÎÊÈ--
- lea edi, source
- mov ecx, 200
- mov al, 0
- repne scasb
- mov eax, 200
- sub eax, ecx
- mov ecx, eax
- dec ecx
- ;---------------------------
- cld ; íàïðàâëåíèå ñëåâà íà ïðàâî
- ;-äîáàâèì ñëóæåáíûå ïðîáåëû â ñòðîêó-
- push ecx
- lea esi, source
- lea edi, string
- rep movsb
- mov ecx, 2
- lea esi, space
- rep movsb
- pop ecx
- add ecx, 2
- ;------------------------------------
- mov ebx, 1 ; ñ÷åò÷èê íîìåðà ñëîâà
- lea esi, string
- mov edi, esi
- mov al, ' '
- repe scasb ; ïðîïóñêàåì ïðîáåë(û) ìåæäó ñëîâàìè
- dec edi
- inc ecx
- mov esi, edi
- cycle: cmp ecx, 0 ; ïðîâåðêà íà îêîí÷àíèå ñòðîêè
- jle ecx_0 ; åñëè çàêîí÷èëàñü - ïðûãàåì ê ìåòêå ecx_o
- lodsb ; çàãðóæàåì ïåðâûé ñèìâîë ñëîâà â AL
- dec ecx ; çàãðóçèëè ñèìâîë - óìåíüøèëàñü è äëèíà ñòðîêè
- ;inc ebx ; óâåëè÷èâàåì ñ÷åò÷èê ñëîâ
- lea edi, vowels ; ÷òîáû ïðîâåðèòü, ÿâëÿåòñÿ ëè ïåðâàÿ áóêâà ñîãëàñíîé (cons)
- push ecx ; ïîìåñòèì â edi âñå ñîãëàñíûå, â ecx - êîë-âî âñåõ ñîãëàñíûõ â àëôàâèòå
- mov ecx, vowels_size
- repne scasb ; ïûòàåìñÿ íàéòè â ñïèñêå ñîãëàñíûõ áóêâó, íàõîäÿùóþñÿ â AL
- pop ecx
- jne not_vowel ; åñëè ïåðâàÿ áóêâà íå ñîãëàñíàÿ - ïðûãàåì íà ìåòêó not_cons
- is_vowel: ; åñëè ñîãëàñíàÿ,òî ïðîâåðÿåì äàëüøå íà ïîñëåäíþþ ãëàñíóþ áóêâó
- mov edi, esi ; ïîñëåäíÿ áóêâà ñëîâà - çíà÷èò, ÷òî îíà èäåò äî ïåðâîãî ïðîáåëà
- mov al, ' '
- repne scasb ; ïîýòîìó íàõîäèì ïðîáåë, â èòîãå ïîïàäàåì íà áóêâó ÏÎÑËÅ ïðîáåëà
- dec edi ; ïîýòîìó äâàæäû øàãàåì íàçàä, ñíà÷àëà ê ïðîáåëó, ïîòîì ê ïîñëåäíåé áóêâå
- dec edi
- add ecx, 2
- mov esi, edi
- lodsb ; çàãðóæàåì â ALïîñëåäíþþ áóêâó ñëîâà
- dec ecx
- lea edi, cons ; òåïåðü òàêæå ïðîâåðÿåì, ÿâëÿåòñÿ ëè áóêâà ãëàñíîé
- push ecx
- mov ecx, cons_size
- repne scasb
- pop ecx
- je con ; åñëè áóêâà ãëàñíàÿ,òî ñëîâà íàì ïîäõîäèò è ïðûãàåì íà vowel
- ;inc esi
- mov edi, esi
- mov al, ' '
- repe scasb ; ïðîïóñêàåì ïðîáåë(û) ìåæäó ñëîâàìè
- dec edi
- inc ecx
- inc ebx
- mov esi, edi
- jmp cycle ; åñëè íå ïîäîøëà, íà÷èíàåì çàíàâî
- con:
- push ecx
- invoke dwtoa, ebx, addr buf ; âûâîäèì íîìåð ñëîâà
- invoke StdOut, ADDR buf
- invoke StdOut, ADDR space
- pop ecx
- inc ecx
- mov edi, esi
- mov al, ' '
- repe scasb ; ïðîïóñêàåì ïðîáåë(û) ìåæäó ñëîâàìè
- dec edi
- mov esi, edi
- inc ebx
- jmp cycle ; âîçâðàøàåìñÿ â íà÷àëî
- not_vowel: ; åñëè ïåðâàÿ áóêâà íå ñîãëàñíàÿ,ñðàçó ïåðåõîäèì ê ñëåäóþ-
- mov edi, esi ; ùåìó ñëîâó, ïðîïóñêàÿ âñå ïðîáåëû
- mov al, ' '
- inc ecx
- repne scasb
- repe scasb
- dec edi
- mov esi, edi
- inc ebx
- jmp cycle
- ecx_0:
- XOR EAX,EAX
- Invoke StdOut,ADDR MsgExit
- Invoke StdIn, ADDR buf, LengthOf buf
- Invoke ExitProcess,0
- End Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement