资源描述:
《汇编语言冒泡排序.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、DATASSEGMENTKEYBUFFERDB100DB?DB100DUP(?)ADB100DUP(?)XDB?TEMPDB?STRING1DB'PLEASEINPUT10NUMBERS:',0DH,0AH,'$'DATASENDSSTACKSSEGMENTSTACK'STACK'DW100HDUP(?)TOPLABELWORDSTACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKS,ES:DATASSTART:MOVAX,DATASMOVDS,AXMOVES,AXMOVAX,S
2、TACKSMOVSS,AXLEASP,TOPLEADX,STRING1MOVAH,09HINT21HLEADX,KEYBUFFERMOVAH,0AHINT21HMOVCX,0AHMOVDI,0LEASI,KEYBUFFER+2JMPLOOP1NEXT1:INCSILOOP1:MOVTEMP,10;MOVX,0MOVDL,[SI]CMPDL,20HJENEXT1SUBDL,'0'MOVAL,DL;十位放到ALMOVDL,[SI+1];个位放到DLCMPDL,20HJENEXTCMPDL,0DHJENEXT;MOVX,AL;个位放入X;
3、MULTEMP;个位乘1;MOVX,AX;MOVAL,10;;TEMP*10;MULTEMP;MOVTEMP,AL;;MULTEMP;MOVAL,DL;MULTEMPADDAL,DLNEXT:MOVA[DI],ALINCDIINCSI;MOVDL,X;INCSI;POPCXLOOPLOOP1MOVCX,10LOP1:MOVSI,0MOVAL,A[SI]MOVBL,10HDIVBLMOVDL,30HADDAL,DLMOVAH,02HINT21HADDAH,DLMOVX,AHMOVAH,02HINT21HINCSILOOPLOP1;MO
4、VCX,9;MOVSI,0;LOOP4:;PUSHCX;LOOP3:;MOVAL,A[SI];CMPAL,A[SI+1];JBCONTINUE;MOVBL,A[SI+1];XCHGAL,A[SI+1];MOVA[SI],BL;CONTINUE:;INCSI;LOOPLOOP3;POPCX;;MOVSI,0;LOOPLOOP4;;LEADX,AMOVAH,9INT21HMOVAH,4CHINT21HCODESENDSENDSTART