-
Notifications
You must be signed in to change notification settings - Fork 0
/
vowel-consonant.asm
117 lines (88 loc) · 1.81 KB
/
vowel-consonant.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
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
.MODEL SMALL
.STACK 100H
.DATA
NEWLINE DB 0AH,0DH,'$'
VOWELS DB 'AaEeIiOoUu$'
VOWEL DB 48
CONSONENT DB 48
DIGIT DB 48
SPACE DB 48
SPACE_MSG DB 'SPACE: $'
DIGIT_MSG DB 'DIGIT: $'
VOWEL_MSG DB 'VOWEL: $'
CONSONENT_MSG DB 'CONSONENT: $'
.CODE
MAIN PROC
MOV AX, DATA
MOV DS, AX
MOV AH, 1
START_INPUT:
INT 21H
CMP AL, 0DH
JE END_INPUT
CMP AL, ' '
JE COUNT_SPACE
CMP AL, '9'
JLE CHECK_DIGIT
MOV SI, 0
MOV CX, 10
CHECK_VOWEL:
CMP AL, VOWELS[SI]
JE COUNT_VOWEL
INC SI
LOOP CHECK_VOWEL
JMP COUNT_CONSONENT
COUNT_SPACE:
ADD SPACE, 1
JMP START_INPUT
CHECK_DIGIT:
CMP AL, '1'
JGE COUNT_DIGIT
JMP START_INPUT
COUNT_DIGIT:
ADD DIGIT, 1
JMP START_INPUT
COUNT_VOWEL:
ADD VOWEL, 1
JMP START_INPUT
COUNT_CONSONENT:
ADD CONSONENT, 1
JMP START_INPUT
END_INPUT:
LEA DX, NEWLINE
MOV AH, 9
INT 21H
LEA DX, SPACE_MSG
MOV AH, 9
INT 21H
MOV DL, SPACE
MOV AH, 2
INT 21H
LEA DX, NEWLINE
MOV AH, 9
INT 21H
LEA DX, DIGIT_MSG
MOV AH, 9
INT 21H
MOV DL, DIGIT
MOV AH, 2
INT 21H
LEA DX, NEWLINE
MOV AH, 9
INT 21H
LEA DX, VOWEL_MSG
MOV AH, 9
INT 21H
MOV DL, VOWEL
MOV AH, 2
INT 21H
LEA DX, NEWLINE
MOV AH, 9
INT 21H
LEA DX, CONSONENT_MSG
MOV AH, 9
INT 21H
MOV DL, CONSONENT
MOV AH, 2
INT 21H
END MAIN