---
title: "8086 ALP: display only alphabetic characters"
subject: "Microprocessor"
chapter: 3
key: "semester_4/microprocessor:alp-8086-alphabetic-only"
source: https://www.bctengineer.com/q/semester_4/microprocessor/alp-8086-alphabetic-only
site: BCT Engineering
---

# 8086 ALP: display only alphabetic characters

Microprocessor · Chapter 3: Programming with 8086 Microprocessor

- Asked in: 2071 Magh, 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-alphabetic-only
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-3

## Question

Write a program to read a string and display only the alphabetic characters from the string in a clear screen.

## Short answer

Read the string with function 0Ah and clear the screen. Classify each character: return 1 for vowel, 2 for consonant, 0 for non-letter. Only display characters whose classification is nonzero using function 02h, so digits, spaces and symbols are skipped. Example: B.C.T 2079! outputs BCT.

## Answer

**Method:** read the string, clear the screen and examine each character with `CLASSIFY` (it returns 0 for non-letters, 1 for vowels and 2 for consonants). Only characters with AL ≠ 0 are displayed, so digits, spaces and symbols are dropped.

```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: $'
    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

    CLRSCR
    LEA  SI,BUF+2
    MOV  CL,BUF+1
    MOV  CH,0
    JCXZ EXIT
NEXT:
    MOV  DL,[SI]
    CALL CLASSIFY          ; AL = 0 -> not a letter
    CMP  AL,0
    JE   SKIP
    MOV  AH,02H            ; letter -> display it
    INT  21H
SKIP:
    INC  SI
    LOOP NEXT
EXIT:
    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

END MAIN
```

**Example:** input `B.C.T 2079!` → output `BCT`.

## Check yourself

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

1. Which characters are displayed?
   A. Only vowels
   B. Those for which CLASSIFY returns a non-zero value
   C. Those for which CLASSIFY returns 0
   D. All characters except spaces
   Answer: B. CLASSIFY returns 0 only for non-letters, so non-zero means a letter. (Key point: Filter rule)

2. What happens to digits, spaces and symbols?
   A. They are shown as blanks
   B. They are converted to letters
   C. They are shown at the end
   D. They are skipped without display
   Answer: D. When AL = 0 the program jumps to SKIP and moves to the next character. (Key point: Dropped characters)

3. What is displayed for input B.C.T 2079! ?
   A. B.C.T
   B. BCT
   C. BCT 2079
   D. B C T
   Answer: B. Only the letters B, C and T are alphabetic. (Key point: Example)

4. What is done between reading the string and displaying letters?
   A. The string is sorted
   B. Digits are converted
   C. The screen is cleared
   D. The string is reversed
   Answer: C. The program calls CLRSCR after input so only the alphabetic output is visible. (Key point: Sequence)

## 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: alternate case display](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-alternate-case) — Microprocessor, chapter 3
- [8086 ALP: largest and smallest, display](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-largest-smallest-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: words on separate lines, centered](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-words-separate-lines-center) — 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

## Related in other subjects

- [Rewrite string characters alphabetically](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astring-alphabetical-order) — Computer Programming, chapter 7
- [Display N characters using default arguments](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3An-chars-default-args-program) — Object Oriented Programming, chapter 3
- [Display characters between given ranges](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Acharacters-between-ranges) — Computer Programming, chapter 5
- [Check string consists of alphabet only](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astring-alphabet-check) — Computer Programming, chapter 7
