-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu_driven_string.asm
143 lines (128 loc) · 2.29 KB
/
menu_driven_string.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
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
data segment
msg1 db 'Enter the string:- $'
str db 80
db 0
db 80 dup (?)
msg2 db 'Number of vowels:- $'
msg3 db 'Palindrome$'
msg4 db 'Not Palindrome$'
msg5 db '1.Number of vowels 2.Check Palindrome Enter your choice:- $'
data ends
extra segment
rev db 80 dup (?)
extra ends
code segment
assume cs:code,ds:data,es:extra
start: mov ax,data
mov ds,ax
mov ax,extra
mov es,ax
lea dx,msg1
mov ah,09h
int 21h
lea dx,str
mov ah,0Ah
int 21h
mov ah,02h
mov dl,0Ah
int 21h
lea dx,msg5
mov ah,09h
int 21h
mov ah,01h
int 21h
cmp al,31h
je vwlcnt
cmp al,32h
je palchk
jmp toend
vwlcnt: mov ah,02h
mov dl,0Ah
int 21h
mov ah,09h
lea dx,msg2
int 21h
lea si,str
inc si
mov cl,[si]
inc si
mov bl,00h
cld
vcnt: mov bh,61h
cmp [si],bh
je cnt
mov bh,65h
cmp [si],bh
je cnt
mov bh,69h
cmp [si],bh
je cnt
mov bh,6Fh
cmp [si],bh
je cnt
mov bh,75h
cmp [si],bh
je cnt
jmp nxt
cnt: inc bl
nxt: inc si
loop vcnt
cmp bl,09h
jg crct
add bl,30h
mov dl,bl
mov ah,02h
int 21h
jmp toend
crct: add bl,06h
mov cx,0000h
mov cl,bl
and bl,0Fh
and cl,0F0h
rol cl,01
rol cl,01
rol cl,01
rol cl,01
add cl,30h
add bl,30h
mov ah,02h
mov dl,cl
int 21h
mov dl,bl
int 21h
jmp toend
palchk: mov ah,02h
mov dl,0Ah
int 21h
mov cx,0000h
lea si,str
inc si
mov cl,[si]
inc si
lea di,rev
mov al,00h
add si,cx
inc cl
cpy: std
lodsb
cld
stosb
loop cpy
mov cl,[si]
cld
inc si
sub di,cx
pchk: cmpsb
jne npal
loop pchk
mov ah,09h
lea dx,msg3
int 21h
jmp toend
npal: mov ah,09h
lea dx,msg4
int 21h
toend: mov ah,4ch
int 21h
code ends
end start