输入一串字符,将字符串的小写字母转成大写字母
程序运行:
代码:
datas segmentoriginalCaseMaxLength db 0ffh,0originalCase db 100h dup(?)uppercase db 100h dup(?)inputPrompt db 'input a line of character:$'outputoriginalCasePrompt db 0dh,0ah,'show noriginal characters:$'outputUppercasePrompt db 0dh,0ah,'turn uppercase characters:$'
datas endsstacks segmentdb 100h dup(?)stacks endscodes segmentassume cs:codes,ds:datas,ss:stacks
main proc far
start:push dsmov ax,0hpush axmov ax,datas ;初始化dsmov ds,axlea dx,inputPrompt ;输出输入提示mov ah,9int 21hlea dx,originalCaseMaxLengthmov ah,10 int 21h;输入并且转换小写字母成大写字 mov cl,originalCaseMaxLength+1 ;记录输入的字符个mov ch,0mov bx,0s:mov al,originalCase[bx]cmp al,'a' jae s1 ;如果al>='a',则跳转s1,判断是否al<='z'jmp s3 ;否则跳s3,直接保存al于uppercases1: cmp al,'z'jbe s2 ;如果al<='z',则al转大写字jmp s3 ;否则跳s3,直接保存al于uppercases2: sub al,20h ;转大写字母s3: mov uppercase[bx],al ;保存al于uppercaseinc bxloop sbreak:mov uppercase[bx+1],'$' ;设置输出字符mov originalCase[bx+1],'$'lea dx,outputoriginalCasePrompt ;输出原始字符提示mov ah,9int 21hlea dx,originalCase ;输出原始字符mov ah,9int 21hlea dx,outputUppercasePrompt ;输出转换字符串提示mov ah,9int 21hlea dx,uppercase ;输出转换字符mov ah,9int 21hretmain endp
codes endsend main