资源描述:
《实验七 字符和数据的显示程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验七字符和数据的显示程序一、实验要求:显示信息“输入字符串,回车或空格结束”,空格或回车后显示输入字符串总字符数,数字字符(1-9)及非数字字符数。二、实验目的:掌握字符和数据的显示方法。三、实验程序框图:四、实验程序:CRLFMACROMOVAH,02HMOVDL,0DHINT21HMOVAH,02HMOVDL,0AHINT21HENDMDATASEGMENTMESS1DB'输入字符串,按空格或回车键结束$'MESS2DB'字符总数=$'MESS3DB'非数字字符总数=$'MESS4DB'数字字符总数=$'TOTALDW?DA
2、TAENDSSTACKSEGMENTSTADW32DUP(?)TOPDW?STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,ES:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVES,AXMOVSP,TOP;初始化MOVBX,0000H;计数值清0MOVAH,09HMOVDX,OFFSETMESS1INT21HCRLFXXX:MOVAH,01HINT21H;接收键入字符CMPAL,20HJZUUU;是空格键则转UUUCMPAL,0DHJNZIIICRLF;是回车键则
3、转UUUJMPUUUIII:CMPAL,30HJBYYYCMPAL,39HJBEVVV;`0-9`转VVVYYY:INCBX;计数值加1VVV:INCTOTALJMPXXXUUU:CRLFMOVAH,09HLEADX,MESS2;显示字符总数INT21HMOVAX,TOTALCALLDISPMOVAH,02HMOVDL,'H'INT21HCRLF;回车换行MOVAH,09HMOVDX,OFFSETMESS3INT21H;显示非数字字符总数MOVAX,BXCALLDISPMOVAH,02HMOVDL,'H'INT21H;十六进制数标
4、志CRLFMOVAH,09HLEADX,MESS4;显示数字字符总数INT21HMOVAX,BXSUBTOTAL,AXMOVAX,TOTALCALLDISPMOVAH,02HMOVDL,'H'INT21HMOVAX,4C00HINT21HDISPPPROCNEAR;显示子程序,显示AL中的数按十六进制数方式MOVBL,AL;AL中数送BLKKK:MOVDL,BLMOVCL,04ROLDL,CLANDDL,0FHCALLDISPL;显示字节高位MOVDL,BLANDDL,0FHCALLDISPL;显示字节低位RETDISPPENDP
5、DISPLPROCNEARADDDL,30H;由数值转为参应字符的ASCII码CMPDL,3AHJBDDD;是0-9转DDDADDDL,27H;是A-FDDD:MOVAH,02HINT21H;显示DL中字符RET;返回DISPLENDP;显示子程序,显示AX中的数按十六进制数方式DISPPROCNEARPUSHBXPUSHCXPUSHDXPUSHAX;入栈保存MOVAL,AHCALLDISPP;显示高字节POPAXCALLDISPPPOPDXPOPCXPOPBXRET;出栈DISPENDPCODEENDSENDSTART