---
title: "8086 ALP: vowels to uppercase, counts"
subject: "Microprocessor"
chapter: 3
key: "semester_4/microprocessor:alp-8086-vowels-uppercase-count"
source: https://www.bctengineer.com/q/semester_4/microprocessor/alp-8086-vowels-uppercase-count
site: BCT Engineering
---

# 8086 ALP: vowels to uppercase, counts

Microprocessor · Chapter 3: Programming with 8086 Microprocessor

- Asked in: 2069 Bhadra, 8 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/microprocessor/alp-8086-vowels-uppercase-count
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-3

## Question

Write a program in 8086 to convert the vowels to uppercase from a string entered by the user and display the converted string in a new line. Also count the number of uppercase letters in the converted string and display the count in a new line.

## Short answer

Read the string and convert each lower-case vowel to upper case by AND 0DFH. Replace the Enter with '$', display the converted string on a new line, then count all 'A' to 'Z' characters in a second pass. Display the count on another new line using PRINT_DEC.

## Answer

**Method:** read the string. For each character, `CLASSIFY` tells whether it is a vowel; a lower-case vowel is converted to upper case (`AND 0DFH`) and stored back. After conversion, the Enter code is replaced by `$`, the string is displayed on a new line, and a second pass counts the upper-case letters ('A' to 'Z', which includes original capitals) and displays the count on another new line.

```asm
.MODEL SMALL
.STACK 100H

DISPSTR MACRO MSG            ; display a '$'-terminated string
        LEA  DX,MSG
        MOV  AH,09H
        INT  21H
        ENDM

CLRSCR  MACRO                ; clear screen and home the cursor
        MOV  AX,0600H        ; scroll whole window (AL=0 -> blank it)
        MOV  BH,07H          ; normal attribute
        MOV  CX,0000H        ; upper-left corner (row 0, col 0)
        MOV  DX,184FH        ; lower-right corner (row 24, col 79)
        INT  10H
        MOV  AH,02H          ; set cursor position
        MOV  BH,00H          ; page 0
        MOV  DX,0000H        ; row 0, col 0
        INT  10H
        ENDM

.DATA
    MSG1  DB 'Enter a string: $'
    MSG2  DB 'Uppercase letters = $'
    UCNT  DB 0
    BUF   DB 80, ?, 80 DUP(0)   ; DOS buffered-input area (max, actual, chars)
    CRLF  DB 13,10,'$'

.CODE
MAIN PROC
    MOV  AX,@DATA
    MOV  DS,AX

    DISPSTR MSG1           ; prompt
    LEA  DX,BUF            ; read the string with DOS function 0Ah
    MOV  AH,0AH
    INT  21H

    LEA  SI,BUF+2
    MOV  CL,BUF+1
    MOV  CH,0
    JCXZ SHOW
CONV:                      ; pass 1 : vowels -> upper case
    MOV  DL,[SI]
    CALL CLASSIFY
    CMP  AL,1
    JNE  NXT1              ; not a vowel
    AND  DL,0DFH           ; make upper case
    MOV  [SI],DL
NXT1:
    INC  SI
    LOOP CONV

    LEA  SI,BUF+2          ; pass 2 : count capital letters
    MOV  CL,BUF+1
    MOV  CH,0
CNT:MOV  AL,[SI]
    CMP  AL,'A'
    JB   NXT2
    CMP  AL,'Z'
    JA   NXT2
    INC  UCNT              ; 'A'..'Z'
NXT2:
    INC  SI
    LOOP CNT
SHOW:
    MOV  BL,BUF+1
    MOV  BH,0
    MOV  BYTE PTR BUF[BX+2],'$'  ; terminate the string
    DISPSTR CRLF           ; new line
    LEA  DX,BUF+2
    MOV  AH,09H            ; show converted string
    INT  21H
    DISPSTR CRLF           ; new line
    DISPSTR MSG2
    MOV  AL,UCNT
    XOR  AH,AH
    CALL PRINT_DEC         ; show count
    MOV  AH,4CH            ; return to DOS
    INT  21H
MAIN ENDP

; ---- classify the character in DL
;      returns AL = 1 vowel, 2 consonant, 0 not a letter (DL unchanged)
CLASSIFY PROC
    MOV  AL,DL
    OR   AL,20H            ; fold to lower case (valid for letters)
    CMP  AL,'a'
    JB   NOTLET
    CMP  AL,'z'
    JA   NOTLET
    CMP  AL,'a'
    JE   VOW
    CMP  AL,'e'
    JE   VOW
    CMP  AL,'i'
    JE   VOW
    CMP  AL,'o'
    JE   VOW
    CMP  AL,'u'
    JE   VOW
    MOV  AL,2              ; consonant
    RET
VOW:MOV  AL,1              ; vowel
    RET
NOTLET:MOV AL,0            ; not a letter
    RET
CLASSIFY ENDP

; ---- print the unsigned number in AX in decimal (registers preserved)
PRINT_DEC PROC
    PUSH AX
    PUSH BX
    PUSH CX
    PUSH DX
    MOV  BX,10
    XOR  CX,CX             ; digit counter
PD1:XOR  DX,DX
    DIV  BX                ; AX = quotient, DX = remainder (digit)
    PUSH DX
    INC  CX
    OR   AX,AX
    JNZ  PD1
PD2:POP  DX                ; digits come out in correct order
    ADD  DL,30H            ; to ASCII
    MOV  AH,02H
    INT  21H
    LOOP PD2
    POP  DX
    POP  CX
    POP  BX
    POP  AX
    RET
PRINT_DEC ENDP

END MAIN
```

**Example:** `Nepal is Nice` → `NEpAl Is NIcE`; capitals N, E, A, I, N, I, E = 7 (the count shown is `7`).

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How is a vowel converted to upper case?
   A. CLASSIFY returns 1, then AND DL,0DFH and the result is stored back
   B. OR DL,20H
   C. Add 20H to every character
   D. Subtract 20H from consonants
   Answer: A. Pass 1 tests for a vowel (AL=1) and clears bit 5 before storing the character back. (Key point: Vowel conversion)

2. Why is a second pass needed?
   A. To count the upper-case letters in the converted string
   B. To read the string again
   C. To clear the screen
   D. To convert the consonants
   Answer: A. The count must include the newly capitalised vowels, so counting happens after conversion. (Key point: Two passes)

3. Which characters does the count include?
   A. Only the converted vowels
   B. All characters between 'A' and 'Z', including original capitals
   C. Only characters above 'Z'
   D. All letters
   Answer: B. The test is 'A' to 'Z', so original capitals are counted as well as converted vowels. (Key point: Count range)

4. For Nepal is Nice, what are the converted string and the count?
   A. NEpAl Is NIcE, 7
   B. nEpAl iS nIcE, 4
   C. NEpAl Is NIcE, 4
   D. NEPAL IS NICE, 11
   Answer: A. Capitals N, E, A, I, N, I, E total 7. (Key point: Example)

## Related in Microprocessor

- [8086 ALP: count vowels and display string](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-count-vowels-display) — Microprocessor, chapter 3
- [8086 ALP: count vowels, consonants, numerals](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-count-vowels-consonants-numerals) — Microprocessor, chapter 3
- [8086 ALP: convert text to uppercase](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-uppercase-text) — Microprocessor, chapter 3
- [8086 ALP: vowels and consonants separately](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-vowels-consonants-separately) — Microprocessor, chapter 3
- [8086 ALP: words on lines and word count](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-words-lines-count) — Microprocessor, chapter 3
- [8086 ALP: alternate case display](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-alternate-case) — Microprocessor, chapter 3
