1) Write a program in assembly language using emu8086 to the handle following cases.
The program takes a character input.
Enter any character From A-Z :
The program must be compatible with emu8086.
DATA SEGMENT
msgEnter db "Enter char: $"
msgWrong db 10,"The wrong input$"
msgUpper db 10,"This is upper case letter$"
msgLower db 10,"This is lower case letter$"
DATA ENDS
CODE SEGMENT
START:
MOV AX,DATA
MOV DS,AX
MOV ES,AX
mov dx, offset msgEnter
mov ah, 9
int 21h
; wait for any key press:
mov ah, 0
int 16h
mov ah, 0eh
int 10h
; Check char
cmp al,'A'
jl _wrong ; char < A
cmp al,'z'
jg _wrong ; char > z
cmp al,'Z'
jg nextCheck ; Z > char < a
jmp displayMsg
nextCheck:
cmp al, 'a'
jl _wrong ; Z < char < a
displayMsg:
; al = char
cmp al, 'a'
jge displayLow
;************************************
mov dx, OFFSET msgUpper ; address of string
mov ah, 9
int 21h ; writes a string
jmp _quit
displayLow:
mov dx, OFFSET msgLower ; address of string
mov ah, 9
int 21h ; writes a string
jmp _quit
_wrong:
mov dx, OFFSET msgWrong ; address of string msgEnter
mov ah, 9
int 21h ; writes a string "The wr "
_quit:
MOV AH,1 ; Waiting for a key press
INT 16H
EXIT_PROG: ; Program is terminated
MOV AH,4CH
INT 21H
CODE ENDS
END START
Comments
Leave a comment