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

# 8086 ALP: convert text to uppercase

Microprocessor · Chapter 3: Programming with 8086 Microprocessor

- Asked in: 2071 Bhadra, 8 marks
- Video: [Convert lowercase to uppercase by assembly language](https://www.youtube.com/watch?v=Rrpz6TKZAcc) — Ahmed Khamis
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/microprocessor/alp-8086-uppercase-text
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-3

## Question

Write an assembly language program to read a text from keyboard, convert the text into uppercase and display on the cleared screen.

## Short answer

Read the string with DOS function 0Ah. For each character in 'a' to 'z', clear bit 5 using AND 0DFH (subtract 20H). Replace the Enter code with '$', clear the screen, and display the converted string with function 09h. Example: Microprocessor 8086 becomes MICROPROCESSOR 8086.

## Answer

**Method:** read the text with function 0Ah. Every lower-case letter ('a' to 'z') is converted to upper case by clearing bit 5 (`AND 0DFH`, i.e. subtracting 20H). Other characters are unchanged. The Enter code (0DH) at the end of the buffer is replaced by `$` so the whole string can be shown with function 09h after the screen is cleared.

```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 text: $'
    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          ; SI -> first character
    MOV  CL,BUF+1          ; number of characters
    MOV  CH,0
    MOV  BX,CX             ; keep the length
    JCXZ SHOW
CONV:
    MOV  AL,[SI]
    CMP  AL,'a'
    JB   NEXT              ; below 'a'
    CMP  AL,'z'
    JA   NEXT              ; above 'z'
    AND  AL,0DFH           ; lower -> upper case
    MOV  [SI],AL
NEXT:
    INC  SI
    LOOP CONV
SHOW:
    MOV  BYTE PTR [SI],'$' ; replace Enter by string terminator
    CLRSCR
    LEA  DX,BUF+2
    MOV  AH,09H            ; display converted text
    INT  21H
    MOV  AH,4CH            ; return to DOS
    INT  21H
MAIN ENDP

END MAIN
```

**Example:** `Microprocessor 8086` → `MICROPROCESSOR 8086`.

## Check yourself

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

1. How is a lower-case letter converted to upper case?
   A. OR with 20H
   B. AND with 0DFH (clear bit 5)
   C. ADD 20H
   D. XOR with 0FFH
   Answer: B. Clearing bit 5 is the same as subtracting 20H for letters a to z. (Key point: Conversion method)

2. Why are CMP with 'a' and 'z' done before AND 0DFH?
   A. To find the string length
   B. To count letters
   C. To make sure only lower-case letters are changed, leaving other characters intact
   D. To switch to signed arithmetic
   Answer: C. Applying AND 0DFH to digits or symbols could change them wrongly, so only 'a' to 'z' are converted. (Key point: Range check)

3. Why is the Enter code replaced with '$'?
   A. Function 09h displays a string only until a '$'
   B. Function 0Ah requires it
   C. The screen clearing needs it
   D. It converts the text to upper case
   Answer: A. INT 21h function 09h prints until it meets '$', so 0DH must be overwritten. (Key point: Terminator)

4. What is the output for Microprocessor 8086?
   A. microprocessor 8086
   B. MICROPROCESSOR
   C. Microprocessor 8086
   D. MICROPROCESSOR 8086
   Answer: D. Letters become capitals and the digits stay unchanged. (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: vowels to uppercase, counts](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-vowels-uppercase-count) — 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: alternate case display](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-alternate-case) — 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 assembly language operators](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3A8086-operators) — Microprocessor, chapter 3, asked 3×

## Related in other subjects

- [8255A card at F3H with keyboard and display](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-f3h-keyboard-display) — Instrumentation II, chapter 2
- [Read switches at port 1, show on port 2](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-switch-port1-led-port2) — Embedded System, chapter 9, asked 2×
- [8255 mode 1 keyboard and printer with decoding](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-keyboard-printer-mode1-fig) — Instrumentation II, chapter 2
- [Edit text: interview body language](https://www.bctengineer.com/question.md?key=semester_5%2Fcommunication_english%3Aedit-text-interview-body-language) — Communication English, chapter 3
