資源描述:
《ARM經(jīng)典匯編程序》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、1冒泡排序的ARM匯編程序ORG09B0HQUE:MOVR3,#50HQUE1:MOVA,R3MOVR0,AMOVR7,#0AHCLR00HMOVA,@R0Q12:INCR0MOVR2,ACLRCMOV22H,@R0CJNEA,22H,Q13SETBCQ13:MOVA,R2JCQ11SETB00HXCHA,@R0DECR0XCHA,@R0INCR0Q11:MOVA,@R0DJNZR7,Q12JB00H,QUE1SJMP$END2ARM匯編希爾排序法對(duì)10個(gè)帶符號(hào)數(shù)進(jìn)行排序Code:voidshell(intsrc[],intl,intr){intih;r++;for(i
2、h=1;ih<(r-l)/9;ih=ih*3+1);//eax,ih//ebx,il//ecx,ir//edx,cmps_asm{pusheaxpushebxpushecxpushedxpushesipushedi;貌似這堆進(jìn)棧用處不大哎movedi,srcmoveax,dwordptr[ih]LIH:cmpeax,0jnaEXIHmovebx,eaxdecebxLLH:cmpebx,dwordptr[r]jnbEXLLHmovecx,ebxmovedx,dwordptr[edi+ecx*4]LCMP:movesi,eaxdecesicmpecx,esijnaEXCMP
3、pushecxsubecx,eaxcmpedx,dwordptr[edi+ecx*4]popecxjnbEXCMPpushebxpushecxsubecx,eaxmovebx,dwordptr[edi+ecx*4]popecxmovdwordptr[edi+ecx*4],ebxpopebxsubecx,eaxjmpLCMPEXCMP:movdwordptr[edi+ecx*4],edxincebxjmpLLHEXLLH:pushecxmovecx,3pushedxcdqidivecxpopedxpopecxjmpLIHEXIH:popedipopesipopedxpop
4、ecxpopebxpopeax}}351單片機(jī)C語言對(duì)流水燈編程,用定時(shí)中斷做#includedefineucharunsignedcharucharm=0,i=0;voidmain(){TMOD
5、=0x01;//定時(shí)器0工作方式為1TH0=(65536-50000)/256;//裝初值TL0=(65536-50000)%256;EA=1;//開總中斷ET0=1;//開定時(shí)器中斷TR0=1;//開啟定時(shí)器while(1);//等待中斷}voidtimer0()interrupt1{TH0=(65536-50000)/256;TL0=(65536-500
6、00)%256;m++;if(m==5)//12M晶振定時(shí)5*50MS=250MS{m=0;P1=~(0X01<
7、0,#78HSETBEASETBEX0SETBET0CLRIT0SJMP$;===int0外部中斷子程序===XC_INT0:PUSHACCPUSHPSWSETBTR0POPPSWPOPACCRETI;===報(bào)警頻率產(chǎn)生T0中斷===BJ_T0:CPLp2.3MOVTH0,#0ECHMOVTL0,#78HRETI5單片機(jī)外部中斷的編程設(shè)計(jì)單片機(jī)程序,基于T0用定時(shí)中斷設(shè)計(jì)秒表,秒計(jì)數(shù)結(jié)果在數(shù)碼管顯示,用外部中斷INT0(邊沿觸發(fā)方式)對(duì)秒計(jì)數(shù)結(jié)果進(jìn)行清零,用P3.0對(duì)秒計(jì)數(shù)進(jìn)行啟動(dòng)和停止控制。T0定時(shí)中斷50毫秒,進(jìn)行20次中斷得到1秒的定時(shí),秒計(jì)數(shù)結(jié)果送P1口進(jìn)行LE
8、D顯示,將外部中斷設(shè)置成邊沿觸發(fā)方式。/***********************************************/#includesbitshiwei=P2^0;//定義接口sbitgewei=P2^1;/*********************************************/unsignedcharcodetable[]={//數(shù)碼顯示表0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};/*******************