Write an assembly program to CHECK NUMBER OF VOWELS
title check number of vowels
dosseg
.model small
.stack 100H
.code
main proc
mov ax, @data ; initialize ds register
mov ds, ax
mov si, offset string
mov cx, length ; length in cx register
mov bl, 00 ; vowel = 0
BACK: mov al, [si]
cmp al, ‘a’ ; alternatively cmp al, 41h for comparing if al =41h
jb AHEAD ; jump below if al < 41, discard
cmp al, ‘z’ ; convert the character to upper case
ja VOWEL
sub al, 20h
VOWEL: cmp al, ‘A’
jnz a3 ; go to a3 to check next vowel character
inc bl ; vowel = vowel + 1
jmp a2 ; jump to increment pointer
a3: cmp al, ‘E’
jnz a4 ; go to a4 to check next vowel character
inc bl ; vowel = vowel + 1
jmp a2 ; jump to increment pointer
a4: cmp al, ‘I’
jnz a5 ; go to a5 to check next vowel character
inc bl ; vowel = vowel + 1
jmp a2 ; jump to increment pointer
a5: cmp al, ‘O’
jnz a6 ; go to a6 to check next vowel character
inc bl ; vowel = vowel + 1
jmp a2 ; jump to increment pointer
a6: cmp al, ‘U’
jmp a2 ; jump to increment pointer
inc bl ; vowel = vowel + 1
a2: inc si
loop BACK
mov VOWEL, bl
mov ax, 4C00H ; return to DOS
int 21H
main endp
.data
string db ‘The quick brown fox jumped over the lazy sleeping dog’, ‘$’
length dw $ string
VOWEL db ?
end main
Visit our download section to download free simulators/ emulators and other essential engineering softwares or join the free update newsletters now.