汇编经典小程序

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

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

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

资源描述

实验一:判断一个数X的正,负数,还是零。(假设是正数,输出+,是负数,输出-,是零,输出Thisisazore!)DATASEGMENTXDB10CREQU0DHLFEQU0AHWDB'Thisisazore!',CR,LF,'$'ZHENGDB'+',CR,LF,'$'FUDB'-',CR,LF,'$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAL,XANDAL,ALJZL1SHLAL,1JCL3JMPL2L1:MOVDX,OFFSETWMOVAH,9INT21HJMPL4L2:MOVDX,OFFSETZHENGMOVAH,9INT21HJMPL4L3:MOVDX,OFFSETFUMOVAH,9INT21HJMPL4L4:MOVAH,4CHINT21HCODEENDSENDSTART实验二:求十个数中的最小数,并以十进制输出。(若要求最大的,只要把JC改为JNC即可)(仅局限于0---16间的数比较,因为ADDAL,30H只是针对一位的十六进制转换十进制的算法)DATASEGMENTXDATDB0AH,1FH,02H,03H,04H,05H,06H,07H,08H,09HMINDB?CREQU0DHLFEQU0AHWDB'ismin',CR,LF,'$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVCX,9MOVSI,OFFSETXDATMOVAL,[SI]L2:CMPAL,[SI+1]JCL1MOVAL,[SI+1]L1:INCSILOOPL2ADDAL,30HMOVDL,ALMOVAH,2INT21HMOVDX,OFFSETWMOVAH,9INT21HCODEENDSENDSTART实验三:设有3个单字节无符号数存放在BUF开始的缓冲区中,编写一个能将它们从大到小从新排列的程序。DATASEGMENTBUFDB87,234,123DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVSI,OFFSETBUFMOVAL,[SI];把3个数取到寄存器中MOVBL,[SI+1]MOVCL,[SI+2]CMPAL,BL;排序,将最大数送AL寄存器JAENEXT1XCHGAL,BLNEXT1:CMPAL,CLJAENEXT2XCHGAL,CLNEXT2:CMPBL,CL;将最小输送CL寄存器JAENEXT3XCHGBL,CLNEXT3:MOV[SI],AL;从大到小依次存回缓冲区,AL,BL,CLMOV[SI+1],BLMOV[SI+2],CLMOVAH,4CHINT21HCODEENDSENDSTART实验三(2):设某一数组的长度为N,个元素均为字数据,试编制一个程序使该数组中的数据按照从小到大的次序排列。(要从大到小排序,只需把JBE改为JAE即可)ADATASEGMENTNEQU10DATADW87,54,78,45,35,23,04H,12H,03H,21HADATAENDSACODESEGMENTASSUMECS:ACODE,DS:ADATASTART:MOVAX,ADATAMOVDS,AXMOVDS,AXMOVBX,0MOVCX,NDECCXLOP1:MOVDX,CXLOP2:MOVAX,DATA[BX]CMPAX,DATA[BX+2]JBECONTIXCHGAX,DATA[BX+2]MOVDATA[BX],AXCONTI:ADDBX,2LOOPLOP2MOVCX,DXMOVBX,0LOOPLOP1MOVAH,4CHINT21HACODEENDSENDSTART实验四:求十个数中的最小数,并以十六进制输出。(若要求最大的,只需把JC改为JNC即可)DATASEGMENTXDATDB0AH,1FH,0FH,0FH,0EH,0BH,0CH,0DH,0EH,0CHTABDB30H,31H,32H,33H,34H,35H,36H,37H,38H,39H,41H,42H,43H,44H,45H,46HMINDB?CREQU0DHLFEQU0AHWDB'ismin',CR,LF,'$'DATAENDSSSEGSEGMENTSTACKDW100DUP(?)SSEGENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVCX,9MOVSI,OFFSETXDATMOVAL,[SI]L2:CMPAL,[SI+1]JCL1MOVAL,[SI+1]L1:INCSILOOPL2CALLDISPPMOVDX,OFFSETWMOVAH,9INT21HMOVAH,4CHINT21HDISPPPROCNEARPUSHDXPUSHCXMOVDL,ALMOVCL,4ROLDL,CLANDDL,0FHCALLDISP1MOVDL,ALANDDL,0FHCALLDISP1POPCXPOPDXRETDISPPENDPDISP1PROCNEARPUSHAXPUSHBXPUSHCXPUSHDXMOVAL,DLMOVBX,OFFSETTABMOVAH,0ADDBX,AXMOVDL,[BX]MOVAH,2INT21HPOPDXPOPCXPOPBXPOPAXRETDISP1ENDPCODEENDSENDSTART

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

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

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

×
保存成功