资源描述:
《实验二 个多位十进制数相加的实验.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验二两个多位十进制数相加的实验CRLFMACRO;建立回车换行宏MOVDL,0DHMOVAH,02HINT21HMOVDL,0AHMOVAH,02HINT21HENDM;宏定义结束DATASEGMENT;数据段DATA1DB33H,39H,31H,37H,34H;第一个数据(作为加数)DATA2DB36H,35H,30H,38H,32H;第二个数据(作为被加数)DATAENDSCODESEGMENT;代码段ASSUMECS:CODE,DS:DATA,ES:DATASTART:MOVAX,DATA
2、MOVDS,AXMOVSI,OFFSETDATA2MOVBX,05CALLDISPL;显示被加数CRLFMOVSI,OFFSETDATA1MOVBX,05CALLDISPL;显示加数CRLFMOVDI,OFFSETDATA2CALLADDA;加法运算MOVSI,OFFSETDATA1MOVBX,05CALLDISPL;显示结果CRLFMOVAX,4C00HINT21HDISPL PROCNEAR;显示子程序段DS1: MOVAH,02H MOVDL,[SI+BX-1];显示字符串中的一个字符 IN
3、T21H DECBX;修改偏移量 JNZDS1 RETDISPL ENDPADDA PROCNEARMOVDX,SIMOVBP,DIMOVBX,05AD1:SUBBYTEPTR[SI+BX-1],30H;将ASCII码表示的数字串SUBBYTEPTR[DI+BX-1],30H;转化位十六进制的字符串DECBXJNZAD1MOVSI,DXMOVDI,BPMOVCX,05;包括进位位共5位CLC;清进位位AD2:MOVAL,[SI]MOVBL,[DI]ADCAL,BL;带进位相加AAA;非组合BCD码
4、的加法调整MOV[SI],AL;结果送加数区INCSIINCDI;指向下一位LOOPAD2;循环MOVSI,DXMOVDI,BPMOVBX,05AD3:ADDBYTEPTR[SI+BX-1],30H;十六进制的数字串转化ADDBYTEPTR[DI+BX-1],30H;为ASCII码表示的数字串DECBXJNZAD3RETADDAENDPCODEENDSENDSTART实验三字符串匹配程序CRLFMACROMOVAH,02HMOVDL,0DHINT21HMOVAH,02HMOVDL,0AHINT21
5、HENDMDATASEGMENTMESS1DB'MATCH',0DH,0AH,'$'MESS2DB'NOMATCH',0DH,0AH,'$'MESS3DB'INPUTSTRING1:',0DH,0AH,'$'MESS4DB'INPUTSTRING2:',0DH,0AH,'$'MAXLEN1DB81ACTLEN1DB?STRING1DB81DUP(?)MAXLEN2DB81ACTLEN2DB?STRING2DB81DUP(?)DATAENDSSTACKSEGMENTSTADB20DUP(?)TOPE
6、QULENGTHSTASTACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACK,ES:DATASTART:MOVAX,DATAMOVDS,AXMOVAX,DATAMOVES,AXMOVAX,STACKMOVSS,AXMOVSP,TOP;段寄存器及堆栈初始化MOVAH,09HMOVDX,OFFSETMESS3INT21H;显示输入提示1MOVAH,0AHMOVDX,OFFSETMAXLEN1INT21H;接收键入的字符串1CRLF;回车换行MOVAH,09
7、HMOVDX,OFFSETMESS4INT21H;显示输入提示2MOVAH,0AHMOVDX,OFFSETMAXLEN2INT21H;接收键入的字符串2CRLFCLDMOVSI,OFFSETSTRING1MOVCL,[SI-1]MOVCH,00H;字符串1的实际字符数送CXKKK:MOVDI,OFFSETSTRING2PUSHCXMOVCL,[DI-1]MOVCH,00H;字符串2的实际字符数送CXMOVAL,[SI]MOVDX,DIREPNZSCASB;将串1中的一个字符和串2中的所有字符作比较
8、JZGGG;比较相等转GGGINCSI;从串1中取下一个字符POPCXLOOPKKKMOVAH,09HMOVDX,OFFSETMESS2INT21H;显示’NOMATCH'JMPPPPGGG:MOVAH,09HMOVDX,OFFSETMESS1INT21H;显示'MATCH'PPP:MOVAX,4C00HINT21H;返回DOSCODEENDSENDSTART实验四字符和数据的显示程序CRLFMACROMOVAH,02HMOVDL,0DHINT21HMOVAH,02HMOVDL,0