汇编_分类统计字符个数(附源代码)

  • 格式:doc
  • 大小:64.00 KB
  • 文档页数:4

2.输入字符,得出结果
备注:源代码附后,源代码要求有注释说明
.386
.model flat
ExitProcess proto near32 stdcall, dwexitcode:dword
INCLUDE io.h
cr EQU 0dh
lf EQU 0ah
.STACK 4096
.DA TA
prompt1 BYTE cr,lf,lf,"Please enter the string(<80).",cr,lf,lf
BYTE "The string is:",0
stringIn BYTE 1 DUP (?)
charLabel BYTE cr,lf,"The number of char is:"
char BYTE 16 DUP (?)
BYTE cr,lf,0
numberLabel BYTE cr,lf,"The number of number is:"
number BYTE 16 DUP (?)
BYTE cr,lf,0
otherLabel BYTE cr,lf,"The number of other is:"
other BYTE 16 DUP (?)
BYTE cr,lf,0
.CODE
_start: output prompt1 ;提示输入字符
mov ax,0
mov bx,0
mov cx,0
begin:
input stringIn,1;输入字符
cmp stringIn,0dh
je forOut ;是回车则结束程序
cmp stringIn,0dh
jb forOther ;ASCII码值小于0dh则其他字符数加1
cmp stringIn,2fh
jbe forOther;ASCII码值小于或等于2fh则其他字符数加1
cmp stringIn,39h
jbe forNumber;ASCII码值小于或等于39h则数字数加1
cmp stringIn,40h
jbe forOther;ASCII码值小于或等于40h则其他字符数加1
cmp stringIn,5ah
jbe forChar;ASCII码值小于或等于5ah则字母数加1
cmp stringIn,60h
jbe forOther;ASCII码值小于或等于60h则其他字符数加1
cmp stringIn,7ah
jbe forChar;ASCII码值小于或等于7ah则字母数加1
jmp forOther;其他字符数加1
forOther: ;其他字符数加1,回到循环开始inc ax
jmp begin
forNumber: ;数字数加1,回到循环开始
inc bx
jmp begin
forChar: ;字母数加1,回到循环开始inc cx
jmp begin
forOut:
itoa other,ax
output otherLabel ;输出其他字符数
itoa number,bx
output numberLabel ;输出数字数
itoa char,cx
output charLabel ;输出字母数
INVOKE ExitProcess,0
PUBLIC _start
END。