-
Notifications
You must be signed in to change notification settings - Fork 0
/
VOWELS.asm
89 lines (78 loc) · 1.86 KB
/
VOWELS.asm
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
Title
.MODEL SMALL
.STACK
.DATA
_STR DB 31 DUP("$")
VOWELS DB "AEIOU","$"
STR_END DB "$"
_LENGTH DW 0000
I DB 0
.CODE
MAIN PROC FAR
MOV AX,@Data
MOV DS,AX
;-------------
CALL READ_STR
CALL STR_LENGTH
LEA SI,VOWELS
MOV CX,5
IS_VOWEL:
CALL CMP_VOWEL
INC SI
DEC CX
JNZ IS_VOWEL
;-------------
MOV AX,4C00H
INT 21H
MAIN ENDP
;------------------
CMP_VOWEL PROC NEAR
PUSH CX
MOV CX,_LENGTH
MOV DH,[SI]
LEA BX,_STR
FIND_VOWEL:
CMP [BX],DH
JE YES
JMP NO
YES:
INC I
NO:
INC BX
DEC CX
JNZ FIND_VOWEL
STOP:
POP CX
RET
CMP_VOWEL ENDP
;---------------------
READ_STR PROC NEAR
MOV CX,30 ;LENGTH LIMITS
LEA DI,_STR
READ_CHAR:
MOV AH,01H
INT 21H
CMP AL,13 ;IS_ENTER_KEY
JE _BREAK
MOV [DI],AL
INC DI
DEC CX
JNZ READ_CHAR
_BREAK:
RET
READ_STR ENDP
;--------------------
; Count length of string -- instead of (LENGTH DW $-MYSTRING)
STR_LENGTH PROC NEAR
LEA BX,_STR
MOV DH,STR_END
A1:
CMP [BX],DH
JE _END
INC _LENGTH
INC BX
JMP A1
_END:
RET
STR_LENGTH ENDP
END MAIN