资源描述:
《单片机考试综合大题编程》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#includesbitgate=P2^0;voidmain(void){unsignedinti,j;while(1){for(i=50000;i>0;i--);for(j=50000;j>0;j--);gate=!gate;}}汇编:org0000hstart:clrp2.0acalldelaysetbp2.0acalldelayajmpstartdelay:movr3,#0ffhdel2:movr4,#0ffhdel1:nopdjnzr4,del1djnzr3,del2retend点亮小灯闪烁定时器隔500ms输出方波ORG0000HM
2、OVR0,#250MAIN:MOVTMOD,#00HMOVTH0,#0E0HMOVTL0,#018HSETBTR0SETBET0SETBEAAJMP$ORG000BHAJMPINQPINQP:MOVTH0,#0E0HMOVTL0,#018HDJNZR0,MAINCPLP1.0RETIENDlp:movr1,#7movr2,#6mova,#0fehmovp2,#0fehacalldelaylp1:rlamovp2,aacalldelaydjnzr1,lp1lp2:rramovp2,aacalldelaydjnzr2,lp2ajmplpdelay:lp3:movr3,#0F4
3、H八只灯闪间隔0.5秒del2:movr4,#0FFHdel1:NOPNOPdjnzr4,del1djnzr3,del2djnzr0,lp3retend模拟霓虹灯org0000hstart:clrp2.0clrp2.1clrp2.2clrp2.3acalldelaysetbp2.0setbp2.1setbp2.2setbp2.3acalldelayajmpstartdelay:movr3,#0ffhdel2:movr4,#0ffhdel1:nopdjnzr4,del1djnzr3,del2retend汽车转向灯控制Org0000hStart:setb20hmovc,20h
4、cplcmovacc.0,csetb21hmovc,21hcplcmovacc.3,cNext:movp2,aacalldelay195msmovp2,#0ffHacalldelay195mssjmpnextdelay195ms:movr3,#07fhdel2:movr4,#0ffhdel1:nopdjnzr4,del1djnzr3,del2retendOrg0000hStart:movp1,#0ffHmova,p1jbacc.0,L1setbacc.0jmpL2L1:clracc.0L2:jbacc.1,L3setbacc.3jmpnextL3:clracc.3Next
5、:movp2,aacalldelay195msmovp2,#0ffHacalldelay195mssjmpstartdelay195ms:movr3,#07fhdel2:movr4,#0ffhdel1:nopdjnzr4,del1djnzr3,del2retend汽车转向灯模拟控制Org0000hsjmpstartorg0003hljmpshacheorg0080hStart:movie,#81hmovtcon,00hmovp1,#0ffHmova,p1jbacc.0,L1setbacc.0汽车转向灯模拟控制刹车情况jmpL2L1:clracc.0L2:jbacc.1,L
6、3setbacc.3jmpnextL3:clracc.3Next:movp2,aacalldelay195msmovp2,#0ffHacalldelay195mssjmpstartshache:clracc.0clracc.3movp2,aacalldelay195msretidelay195ms:movr3,#07fhdel2:movr4,#0ffhdel1:nopdjnzr4,del1djnzr3,del2retend汽车转向灯控制全中断Org0000hsjmpstartorg0003hljmpzhongduan1org0080hStart:movie,#81hmov
7、tcon,00hmovp2,#0ffHsjmpstartzhongduan1:movp1,#0ffHmova,p1jnbacc.0,shachejnbacc.1,leftjnbacc.2,rightretishache:clracc.0clracc.3movp2,aacalldelay195msretileft:clracc.0setbacc.3movp2,aacalldelay195msmovp2,#0ffHacalldelay195msretiright:setbacc.0clracc.3movp2,aacalldelay