输入一个字符,输出该字符的前导后字符
程序运行:
代码:
datas segmenta db ?inputPrompt db 'input a lowercase character:$'outputPrompt db 0dh,0ah,'output leading and successor character:$'outputLeadingCharacterPrompt db 0dh,0ah,'leading character:$'outputSuccessorCharacterPrompt db 0dh,0ah,'successor character:$'outputErrorPrompt db 0dh,0ah,'input is invalid!$'
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 21hmov ah,1int 21hcmp al,'a' jae s1 ;如果al>='a',则跳转s1,判断是否al<='z'jmp s3 ;否则跳s3s1: cmp al,'z'jbe lowercaseCharacter ;如果al<='z',则al转大写字母jmp s3 ;否则跳s3lowercaseCharacter:mov a,allea dx,outputPrompt ;输出前导字母和后继字母提示mov ah,9int 21h;lea dx,outputLeadingCharacterPrompt ;输出前导字母提示;mov ah,9;int 21hmov al,a ;输出前导字母mov ah,0add ax,26-'a'-1mov bl,26div blmov dl,ahadd dl,'a'mov ah,2int 21hmov dl,a ;输出输入字母mov ah,2int 21h;lea dx,outputSuccessorCharacterPrompt ;输出后继字母串提示;mov ah,9;int 21hmov al,a ;输出后继字母mov ah,0add ax,26-'a'+1mov bl,26div blmov dl,ahadd dl,'a'mov ah,2int 21hjmp exit s3:lea dx,outputErrorPrompt ;输出输入无效mov ah,9int 21hexit:retmain endp
codes endsend main