Assembly Program to Count Vowels in a String
The program will prompt the user to input a string and will count the number of vowels present in that string.
The program takes a string and stores the string in STRING and will start iteration if there is a consonant the program will continue without incrementing VOWELS and if there is a VOWEL the program will increment VOWELS. After counting the vowels the program simply prints the number of vowels.
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 | .MODEL SMALL .STACK 100H .DATA STRING DB 100 DUP(?) MSG1 DB "ENTER A STRING: $" MSG2 DB 0DH, 0AH, "NO. OF VOWELS_FOUNDS: $" VOWELS DW 0 .CODE MAIN PROC MOV AX, @DATA MOV DS, AX MOV ES, AX MOV AH, 9 LEA DX, MSG1 INT 21H LEA DI, STRING MOV AH, 1 READ: INT 21H CMP AL, 0DH JE ENDOFSTRING STOSB JMP READ ENDOFSTRING: MOV AL, "$" STOSB XOR BX, BX COUNT: MOV AL, STRING[BX] CMP AL, "$" JE EXIT CMP AL, "a" JE VOWEL_FOUND CMP AL, "e" JE VOWEL_FOUND CMP AL, "i" JE VOWEL_FOUND CMP AL, "o" JE VOWEL_FOUND CMP AL, "u" JE VOWEL_FOUND CMP AL, "A" JE VOWEL_FOUND CMP AL, "E" JE VOWEL_FOUND CMP AL, "I" JE VOWEL_FOUND CMP AL, "O" JE VOWEL_FOUND CMP AL, "U" JE VOWEL_FOUND INC BX JMP COUNT VOWEL_FOUND: MOV CX, VOWELS INC CX MOV VOWELS, CX INC BX JMP COUNT EXIT: MOV AH, 9 LEA DX, MSG2 INT 21H MOV AH, 2 MOV DX, VOWELS ADD DX, 30H INT 21H MAIN ENDP END MAIN |
I’m excited to uncover this page. I need to to thank you for ones time for this particularly fantastic read!! I definitely really liked every part of it and i also have you saved to fav to look at new information in your site.
ReplyDeleteData Analytics Training in Hyderabad | Business Analytics Training in Hyderabad | Data Analytics Course in Hyderabad | Business Analytics Course | Data Analytics Course
Attend The Data Analyst Course From ExcelR. Practical Data Analyst Course Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Analyst Course.
ReplyDeleteData Analyst Course