您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 其它行业文档 > 8086汇编经典例程
==========================================5.编写一个数组排序(从小到大)的小程序,数组在程序中定义,程序先将原数组显示一遍,然后排序,再将排好序的数组显示一遍。==========================================AAASEGMENTBUFDB'6455412345$'L=$-BUFarydw-897,345,6789,8654,-1234,-3456,-99,-678,987,567,32762,-12121,0,3434,4645,-234,23455,-100,100,1000,-1000dw572,-2345,-6543,-1234,9999lendw($-ary)/2ASSUMECS:AAA,DS:AAAMAINPROCFARPUSHCSPOPDSLEASI,ARYMOVCX,LENNEXT3:MOVBX,[SI]CALLDISPCALLSPACEADDSI,2LOOPNEXT3CALLCRLFCALLCRLFLEASI,ARYMOVCX,LENCALLSORTLEASI,ARYMOVCX,LENNEXT5:MOVBX,[SI]CALLDISPCALLSPACEADDSI,2LOOPNEXT5MOVAH,4CHINT21HMAINENDPDISPPROCPUSHSIPUSHAXPUSHBXPUSHDXPUSHCXMOVCX,0CMPBX,0JNLNEXT1NEGBXMOVCX,1NEXT1:LEASI,BUF+l-1MOVAX,BXMOVBX,10NEXT:MOVDX,0DIVBXADDDL,30HDECSIMOV[SI],DLCMPAX,0JNENEXTCMPCX,0JENEXT2DECSIMOVBYTEPTR[SI],'-'NEXT2:MOVDX,SIMOVAH,9INT21HPOPCXPOPDXPOPBXPOPAXPOPSIRETDISPENDPSORTPROCNEXTT:PUSHCXMOVDI,SIMOVAX,[SI]NEXT0:CMPAX,[DI]JLNEXTQMOVBX,AXMOVAX,[DI]MOV[DI],BXNEXTQ:ADDDI,2LOOPNEXT0MOV[SI],AXADDSI,2POPCXLOOPNEXTTRETSORTENDPCRLFPROCPUSHAXPUSHDXMOVDL,13MOVAH,2INT21HMOVDL,10INT21HPOPDXPOPAXRETCRLFENDPSPACEPROCPUSHAXPUSHDXMOVDL,''MOVAH,2INT21HPOPDXPOPAXRETSPACEENDPAAAENDSENDMAIN===============================================6.编写一个程序,从键盘输入10个十进制数字字符,然后将这些数字加密存储在缓冲区BUFFER中。加解密表如下:==========================================qqqsegmentTAB1DB'QWERTYUIOPASDFGHJKLZXCVBNM'TAB2DB'qazwsxedcrfvtgbyhnujmikolp'TAB3DB')(*&^%/#@!'LEN=$-tab1MSS1DB13,10,'Pleasechoseafunctioc:',0DH,0AHDB'1--jiami',0DH,0AHDB'2---jiemi',13,10DB'0--exit$'MSS2DB0dh,0ah,'Error!Youhavepresskey!$'MM1DB'Yourinputis:'BUF1DB255DUP(?)MM2DB'Myoutputis:'BUF2DB255DUP(?)qqqendscccsegmentassumecs:ccc,ds:qqqmainprocfarstart:movax,qqqmovds,axrep1:callcrlfLEASI,BUF1LEADI,BUF2leadx,mss1;显示菜单movah,9int21hmovah,1;输入你的选项int21hcmpal,'0';输入0,结束jequitcmpal,'1';输入1,加密jejiamicmpal,'2';输入2,解密jejiemimov[mss2+25],al;其他字符,错误,重输入leadx,mss2movah,9int21hjmprep1quit:movah,4chint21hjiami:callcrlfnext1:movah,1int21hcmpal,27jeNEXT14MOV[SI],ALcmpal,'A'jnaenext3cmpal,'Z'janext3subal,'A'leabx,tab1jmpnext10next3:cmpal,'a'jnaenext4cmpal,'z'janext4subal,'a'leabx,tab2jmpnext10next4:cmpal,'0'jbnext13cmpal,'9'janext13leabx,tab3subal,'0'next10:xlatnext13:MOV[DI],ALINCSIINCDIjmpnext1next14:MOVBYTEPTR[SI],24HMOVBYTEPTR[DI],24HCALLCRLFLEADX,MM1MOVAH,9INT21HCALLCRLFLEADX,MM2INT21HJMPREP1jiemi:callcrlfnext18:movah,1int21hcmpal,27jeNEXT14MOV[SI],ALmovbx,0next20:cmpal,tab1[bx]jenext22incbxcmpbx,62jbnext20jmpnext40next22:cmpbx,26jaenext23moval,'A'addal,bljmpnext40next23:cmpbx,52jaenext24subbl,26moval,'a'addal,bljmpnext40next24:subbl,52moval,'0'addal,blnext40:MOV[DI],ALINCSIINCDIjmpnext18mainendpcrlfprocpushaxpushdxmovah,2movdl,13int21hmovdl,10int21hpopdxpopaxretcrlfendpcccendsendstart==========================================7.编写一个发声的小程序,通过程序使PC喇叭发出声音==========================================PROGSEGMENTMAINPROCFARASSUMECS:PROG,DS:PROGSTART:MOVDX,0000;计产生1,0次数INAL,61H;取得设备控制字ANDAL,0FCH;使AL最低两位为0CHANG:XORAL,3;改变输出值OUT61H,AL;输出到61H端口,扬声器发声MOVCX,00H;延时计数器WAIT1:LOOPWAIT1;延时DECDXJNECHANGMOVAH,4CHINT21H;返回系统PROGENDSENDSTART==========================================8.编写一个唱歌的小程序,通过程序使PC喇叭发出声音演奏歌曲==========================================;这是一个音乐程序,按大写字母“A”,唱乐曲“玛丽有只小羔羊”;;按大写字母“B”,唱乐曲“太湖船”;按大写字母“C”,唱乐曲“祝福歌”;按Q鍵,退出DATASEGMENTPARA'DATA'INFO1DB0DH,0AH,'WELCOMETOCOMEHERE!$'INFO2DB0DH,0AH,'thisisamusicprogram!$'INFO3DB0DH,0AH,'pleaseselect!$'INFO4DB0DH,0AH,'INPUTERROR!$'INFO5DB0DH,0AH,'PLEASEINPUTAGAIN!$'MUSLISTDB0DH,0AH,'AMUSIC1'DB0DH,0AH,'BMUSIC2'DB0DH,0AH,'CMUSIC3'DB0DH,0AH,'QEXIT'DB0DH,0AH,'$'MUS_FREG1DW330,294,262,294,3DUP(330)DW3DUP(294),330,392,392DW330,294,262,294,4DUP(330)DW294,294,330,294,262,-1MUS_TIME1DW6DUP(25*8),50*8DW2DUP(25*8,25*8,50*8)DW12DUP(25*8),100*8MUS_FREG2DW330,392,330,294,330,392,330,294,330DW330,392,330,294,262,294,330,392,294DW262,262,220,196,196,220,262,294,332,262,-1MUS_TIME2DW3DUP(50),25,25,50,25,25,100DW2DUP(50,50,25,25),100DW3DUP(50,25,25),100MUS_FREG3DW262,262,294,262,349DW330,262,262,294,262DW392,349,262,262,523DW440,349,262,262,466DW466,440,262,392,349,-1MUS_TIME3DW50,50,100,100,100DW100,100,50,50,100,100DW100,100,100,50,50,100DW100,100,100,100,100,50DW50,100,100,100,100,100DATAENDSSTACKSEGMENTPARASTACK'STACK'DB200DUP('STACK')STACKENDS;*****定义一个宏*****SHOWMACRObLEADX,bMOVAH,9INT21HENDM;**********************CODESEGMENTASSUMEDS:DATA,SS:STACK,CS:CODEMAINPROCFARMOVAX,DATAMOVDS,AXMOVAH,0;0号功能MOVAL,4;显示方式号4放在;AL中320*200四色图形INT10H;显示器输出控制中断调用MOVAH,0BH;置彩色调色板MOVBH,0MOVBL,1;BH=0,BL=4,背景色为红色INT10H;显示器输出控制中断调用MOVAH,0BHMOVBH,01HMOVBL,00INT10H;显示器输出控制中断调用showINFO1showINFO2showINFO3showMUSLISTINPUT:MOVAH,01HINT21HCMPAL,'Q'JZretuCMPAL,'A'JNZB0LEASI,MUS_FREG1LEABP,DS:MUS_TIME1CALLMUSICJMPEXIT1B0:CMPAL,'B'JNZC0LEASI,MUS_FREG2LEABP,DS:MUS_TIME2CALLMUSICJMPEXIT1C0:CMPAL,'C'JNZexitLEASI,MUS_FREG2LEABP,DS:MUS_TIME2CALLMUSICEXIT1:showINFO5JMPINPUTEXIT:callclearshowINFO4showINFO5showINFO1showINFO2showINFO3showMUSLISTjmpinputRETU:MOVAH,4CHINT21HMAINENDPMUSICPROCNEARFREG1:MOVDI,[SI]CMPDI,-1JEEND_MUS1MOVDX,DS:[BP]MOVBX,1400CALLGENSOUNDADDSI,2ADDBP,2JMPFREG1END_MUS1
本文标题:8086汇编经典例程
链接地址:https://www.777doc.com/doc-6759983 .html