标签:byte img 根据 out flat har 技术 upper code
1. 题目:大小写字母字符互换
2. 要求:从键盘输入一个字符,如果该字符是回车符,直接退出程序,如果是小写字母,则转换为大写字母并显示;如果是大写字母,则转换为小写字母并显示;如果是非字母字符,则显示提示信息,并等待用户重新输入字符。
3. 提示: 首先判断是否是回车符,如果不是,则判断是否是大写字母或小写字母,如果是进行转换并输出,否则显示重新输入。大写字母ASCII码与小写字母ASCII之间相差20H,可以根据这个进行转换。
1 ; Example assembly language program -- 2 ; Author: karllen 3 ; Date: revised 5/2014 4 5 .386 6 .MODEL FLAT 7 8 ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD 9 10 INCLUDE io.h ; header file for input/output 11 12 cr EQU 0dh ; carriage return character 13 Lf EQU 0ah ; line feed 14 15 .STACK 4096 ; reserve 4096-byte stack 16 17 .DATA 18 promot BYTE "Enter a char of letter ",cr,Lf,0 19 warning BYTE "The char isn‘t a letter,enter again ",0 20 21 answerLtoU BYTE "The char is a lowercase,it‘s uppercase is " 22 BYTE cr,Lf,0 23 answerUtoL BYTE "The char is a uppercase,it‘s lowercase is " 24 BYTE cr,Lf,0 25 char BYTE 1 DUP(?) 26 .CODE 27 _start: 28 output promot 29 input char,1 30 doGo: 31 mov bl,char 32 input char,1 33 cmp char,0dh 34 je doWhCMP ;cr deal the cr 35 jmp doGo 36 doWhCMP: 37 38 cmp bl,41h 39 jl inputAgain ;the char < A,end and input again 40 cmp bl,5Ah 41 jle endUppertoL ;the char <= Z,so to judge it is or not lowercase 42 ;the char is a uppercase 43 cmpLower: 44 cmp bl,61h ;the char < a,end and input again 45 jl inputAgain 46 cmp bl,7Ah ;the char > z.end and input agian 47 jg inputAgain 48 jmp endLowertoU ;the char is a lowercase 49 50 inputAgain: 51 output warning 52 input char,1 53 mov bl,char 54 jmp doGo 55 endUppertoL: 56 mov al,bl 57 add al,32 ;这里是十进制加减 58 mov char,al 59 output answerUtoL 60 output char 61 jmp endMain 62 endLowertoU: 63 mov al,bl 64 sub al,32 65 mov char,al 66 output answerLtoU 67 output char 68 endMain: 69 70 INVOKE ExitProcess, 0 ; exit with return code 0 71 72 PUBLIC _start ; make entry point public 73 74 END ; end of source code
标签:byte img 根据 out flat har 技术 upper code
原文地址:http://www.cnblogs.com/xieyulin/p/7056432.html