- 2071 Bhadra · 8 marks
8086 ALP: convert text to uppercase
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.
Write an assembly language program to read a text from keyboard, convert the text into uppercase and display on the cleared screen.
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.
.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.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- 8086 ALP: count vowels and display string · Microprocessor, chapter 3
- 8086 ALP: vowels to uppercase, counts · Microprocessor, chapter 3
- 8086 ALP: largest and smallest, display · Microprocessor, chapter 3
- 8086 ALP: alternate case display · Microprocessor, chapter 3
- 8086 ALP: words on lines and word count · Microprocessor, chapter 3
- 8086 assembly language operators · Microprocessor, chapter 3 · asked 3×
- 8255A card at F3H with keyboard and display · Instrumentation II, chapter 2
- Read switches at port 1, show on port 2 · Embedded System, chapter 9 · asked 2×
- 8255 mode 1 keyboard and printer with decoding · Instrumentation II, chapter 2
- Edit text: interview body language · Communication English, chapter 3