两个汇编程序(求累加和):第一题:从键盘输入一个十进制数n,计算1+2+3+4+……+n=sum,并以此格式输出。(结果超过65535时会溢出)代码:DATASEGMENTINF1DBPleaseInputaNumber(0~65535):$IBUFDB7,0,6DUP(?)OBUFDB6DUP(?)STRINGDB1+2+......+$ZHONGZHIDB6DUP(?)GESDW?SUMDW?MDDW0DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVDX,OFFSETINF1;输出提示语句MOVAH,09HINT21HMOVDX,OFFSETIBUF;从键盘输入一个十进制数n(字符串)命令MOVAH,0AHINT21HMOVCL,IBUF+1;将输入的串转换为数值存于AX中MOVCH,0MOVSI,OFFSETIBUF+2MOVAX,0AGAIN:MOVDX,10MULDXANDBYTEPTR[SI],0FHADDAL,[SI]ADCAH,0INCSILOOPAGAINMOVGES,AX;保存输入的n;计算过程:1+2+3+…..+nMOVCX,AXMOVAX,0MOVMD,1LOOP1:ADDAX,MDINCMDLOOPLOOP1MOVSUM,AXSHUCHU:MOVDL,0AH;换行输出MOVAH,2INT21HMOVDL,0DHMOVAH,2INT21HMOVDX,OFFSETSTRING;输出“1+2+......+”MOVAH,09HINT21HMOVAX,GESMOVBX,OFFSETZHONGZHI+5MOVBYTEPTR[BX],'$'MOVCX,10LOOP2:MOVDX,0DIVCXADDDL,30HDECBXMOV[BX],DLORAX,AXJNZLOOP2MOVDX,BXMOVAH,09HINT21H;输出“=”MOVDL,'='MOVAH,2INT21HMOVAX,SUMMOVBX,OFFSETOBUF+5MOVBYTEPTR[BX],'$'MOVCX,10LOOP3:MOVDX,0DIVCXADDDL,30HDECBXMOV[BX],DLORAX,AXJNZLOOP3MOVDX,BXMOVAH,09HINT21HFINISH:MOVAH,4CH;结束INT21HCODEENDSENDSTART结果截屏:╬┤└┤╗π▒α╓╨╬─╤º╧░░µ1.00PleaseInputaNumber(0~65535):1001+2+......+100=5050Pressanykeytocontinue...第二题:从1+2+3+……一直累加,当结果大于6000时结束,并输出结果:1+2+3+……+n=sum代码:DATASEGMENTINF1DB0AH,0DH,PleaseInputaNumber(0~65535):$STRINGDB0AH,0DH,1+2+......+$IBUFDB7,0,6DUP(?)GESHUDB6DUP(?)JIEGUODB6DUP(?)SUMDW?MDDW0DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVDX,OFFSETSTRING;换行输出“MOVAH,09HINT21HMOVAX,0;计算过程1+2+3+......直到结果大于60000MOVMD,1LOOP1:ADDAX,MDINCMDCMPAX,60000JBELOOP1MOVSUM,AXMOVAX,MD;输出个数(加到多少为止)MOVBX,OFFSETGESHU+5MOVBYTEPTR[BX],'$'MOVCX,10LOOP2:MOVDX,0DIVCXADDDL,30HDECBXMOV[BX],DLORAX,AXJNZLOOP2MOVDX,BXMOVAH,09HINT21HMOVDL,'=';输出“=”MOVAH,2INT21HMOVAX,SUM;输出总和MOVBX,OFFSETJIEGUO+5MOVBYTEPTR[BX],'$'MOVCX,10LOOP3:MOVDX,0DIVCXADDDL,30HDECBXMOV[BX],DLORAX,AXJNZLOOP3MOVDX,BXMOVAH,09HINT21HFINISH:MOVAH,4CH;结束INT21HCODEENDSENDSTART结果截屏:╬┤└┤╗π▒α╓╨╬─╤º╧░░µ1.001+2+......+347=60031Pressanykeytocontinue...