汇编语言实现十个数的排序

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

DATASSEGMENTDATA0DB'Pleaseinputanumbers(0-65535):','$'DATA1DB'overflowinputagain:','$'DATA2DB'Thenumyouhaveputis:',0ah,0dh,'$'DATA3DB'Afterexchangethenumis:',0ah,0dh,'$'DATA4DB'','$'DATADW10DUP(?)DATASENDSSTACKSSEGMENTDW256DUP(?);此处输入堆栈段代码STACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKS;/****************************************/;-----------程序开始------------START:MOVAX,DATASMOVDS,AXMOVSI,0MOVCX,10;----------循环输入------------L:CALLINPUTADDSI,2CALLNEWLINELOOPLMOVDX,OFFSETDATA2MOVAH,9INT21H;-------输入后显示----------MOVCX,10MOVDI,0AGAIN:CALLPRINTCALLSPACEADDDI,2LOOPAGAIN;----------排序-------------MOVCX,9MOVDI,0LOOP0:CALLSORTADDDI,2LOOPLOOP0CALLNEWLINEMOVDX,OFFSETDATA3MOVAH,9INT21H;----------交换后显示-------------MOVCX,10MOVDI,0AGAIN0:CALLPRINTCALLSPACEADDDI,2LOOPAGAIN0;----------返回系统--------------EXIT:MOVAH,4CHINT21H;/**************************************/;------------输入函数--------INPUTPROCNEARPUSHAXPUSHBXPUSHCXPUSHDX;----------提示信息----------MOVDX,OFFSETDATA0MOVAH,9INT21HMOVBX,0;BX存放十进制数CLCMOVDX,0L0:;----------输入数字----------MOVAH,1INT21HCMPAL,0DHJEL1SUBAL,30HJLNEXT1CMPAL,9JGNEXT1;---------转换成十进制数-------MOVAH,0XCHGAX,BXMOVCX,10MULCXADDAX,BXJCNEXT1XCHGAX,BXJMPL0NEXT1:MOVDX,0MOVBX,0CALLNEWLINECALLERRORJMPL0L1:CMPDX,0JNZNEXT1MOVDATA[SI],BXMOVDX,0POPDXPOPCXPOPBXPOPAXRETINPUTENDP;/*****************************/;-------回车换行--------NEWLINEPROCNEARPUSHAXPUSHDXMOVDL,0AHMOVAH,2INT21HMOVDL,0DHMOVAH,2INT21HPOPDXPOPAXRETNEWLINEENDP;/*********************************/;--------空格-------SPACEPROCNEARPUSHAXPUSHDXMOVDX,OFFSETDATA4MOVAH,9INT21HPOPDXPOPAXRETSPACEENDP;/**************************************/;----------错误提示----------------ERRORPROCNEARPUSHAXPUSHDXMOVDX,OFFSETDATA1MOVAH,9INT21HPOPDXPOPAXRETERRORENDP;/************************************/;--------冒泡排序子程序-----------SORTPROCNEARPUSHBXPUSHDXMOVSI,DILOOP1:ADDSI,2MOVBX,DATA[DI]CMPBX,DATA[SI]JACHANGEJMPNEXTCHANGE:MOVDX,DATA[SI]MOVDATA[DI],DXMOVDATA[SI],BXNEXT:CMPSI,18JLLOOP1POPDXPOPBXRETSORTENDP;/***********************************/;-----------显示函数--------PRINTPROCNEARPUSHAXPUSHBXPUSHCXPUSHDXMOVCX,0MOVBX,10MOVAX,DATA[DI]LAST:MOVDX,0DIVBXPUSHDXINCCXCMPAX,0JNZLASTAGE:POPDXORDX,30HMOVAH,2INT21HLOOPAGEPOPDXPOPCXPOPBXPOPAXRETPRINTENDPCODESENDSENDSTART

1 / 6
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功