资源描述:
《汇编语言求平均数.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、;--------------------------------------------;;Name:平均数计算;;Desccription:连续输入十个10以下的数,程序计-;;算去掉一个最小数,去掉一个最大数后八个数的平;;均值,从显示器显示出来,结果保留3位小数-----;;Author:160409108;;Date:2011-11-12;;--------------------------------------------;DATASEGMENTBUFDB?ORG10HTABLEDB?BUF1DB'PLEASEENTER10NUMBE
2、RS$'BUF2DB'THEAVERAGEIS$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEADX,BUF1MOVAH,9INT21H;显示提示信息‘PLEASEENTER10NUMBERS’MOVAH,02HMOVDL,0AHINT21H;换行MOVCX,10LEADI,BUFLP1:;连续输入10个数MOVAH,1INT21HSUBAL,30H;asc码转bcd码MOV[DI],ALINCDIMOVDL,20H;输入中插入空格MOVAH,02HINT21HL
3、OOPLP1MOVCH,10DECCHLOP0:MOVSI,OFFSETBUF;冒泡排序法MOVCL,CHXORBL,BLLOP1:MOVAL,[SI]CMPAL,[SI+1]JLENEXTXCHGAL,[SI+1]MOV[SI],ALORBL,01HNEXT:INCSIDECCLJNZLOP1ANDBL,BLJZSTOPDECCHJNZLOP0STOP:MOVSI,OFFSETBUFMOVDI,OFFSETTABLEINCSI;从第二个数开始存数据MOVCX,8MOVAX,0LOP3:ADDAL,[SI];相加得到和INCSILOOPLOP3MOV
4、[DI],AL;和存入DLMOVCL,8;CL=8DIVCL;AX/CL商>AL余数>AHINCDIMOV[DI],AL;商INCDIMOV[DI],AH;余数MOVAL,AH;余数存入ALMOVAH,0MOVCX,3LOP4:MOVBL,10MULBL;余数x10MOVBH,8DIVBH;除8求商求余INCDIMOV[DI],ALINCDIMOV[DI],AHMOVAL,AHMOVAH,0LOOPLOP4MOVDI,OFFSETTABLEMOVAH,02H;换行MOVDL,0AHINT21HLEADX,BUF2MOVAH,9INT21H;显示提示信
5、息‘THEAVERAGEIS’MOVAH,02HMOVDL,0AHINT21H;换行MOVDL,[DI+1];依次显示数据ADDDL,30H;个位数MOVAH,2INT21HMOVDL,2EH;小数点MOVAH,2INT21HMOVDL,[DI+3];第一位小数ADDDL,30HMOVAH,2INT21HMOVDL,[DI+5];第二位小数ADDDL,30HMOVAH,2INT21HMOVDL,[DI+7];第三位小数ADDDL,30HMOVAH,2INT21HMOVAH,4CH;返回DOSINT21HCODEENDSENDSTART