文档库 最新最全的文档下载
当前位置:文档库 › 汇编语言程序,键盘输入的小写字母用大写字母显示出来

汇编语言程序,键盘输入的小写字母用大写字母显示出来

;要求对键盘输入的小写字母用大写字母显示出来

data segment
message db 'please enter the small letter:',0ah,0dh,'$'
message2 db 'the capital letter is:',0ah,0dh,'$'
error db 'enter must be small!please enter again:',0ah,0dh,'$'
message3 db 'the capital letter is:','$'
letter db 8
data ends
stack segment
db 100h dup(0)
stack ends
code segment
assume cs:code,ds:data,ss:stack
start: mov ax,data
mov ds,ax
jmp l1
xor ax,ax ;ax清零
error1:lea dx,error
mov ah,09h ;显示字符串
int 21h
l1:lea dx,message
mov ah,09h
int 21h
lea dx,letter
mov ah,01h ;键盘输入并回显
int 21h
push ax
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
int 21h
lea dx,message3
mov ah,09h
int 21h
pop ax
cmp al,'z' ;比较,判断是否小写字母
ja error1 ;大于'z',不是小写字母
cmp al,'a'
jb error1 ;小于‘a’,大写字母重新输入
sub al,20H ;减 20H转换为大写字母
mov dl,al
mov ah,02h;显示字符
int 21h
mov ax,4c00h ;程序正常结束
int 21h
code ends
end start

相关文档
相关文档 最新文档