1、单片机应用技术模拟试卷(G)答案题号二四总分得分一,程序分析题(共2题,每题10分,共20分)1,调试以下程序段,写出每条指令执行后地结果MOVR1,#35H ;(R1)= 35HMOV A,#26H; (A)=26HADD A,#47H; (A)= 6DH ,(CY)=0MOV R1,A;(R1)=35H2,程序采用定时器/计数器控制,使LED亮1S,灭1S,周而复始。二,程序纠错题(共3题,每题10分,共30分)LA= 31H B= 30HSP= 2FH2 .(ROA 7EH ,(7EH)= FFH,(7FH)= 3FH3 , org OOOOhmov 20h,#lmov 30h,#2mo
2、v r0,#20hmov rl,#30hmov a,rOmov b,rlmov rO,bmov rl,aend三,程序填空题(共2题,每题10分,共20分)1,#TAB (1 分)MOVC A, A+DPTR (2 分)MOV Pl, A (1 分)INC R0 (1 分)功能分析酌情给分2,switch(i)(case 1: PO=Oxfe; break;case 2: PO=Oxfd; break;case 3:P0=0xfb; break;case 4:P0=0xf7; break;case 5: PO=Oxef; break;case 6: PO=Oxdf; break;case 7:
3、 PO=Oxbf; break;case 8: P0=0x7f; break;default: PO=Oxff;四,编程设计题(共2题,每题15分,共30分)1,参考答案:#include #include #define uchar unsigned char#define uint unsigned intSbit LEDl=P0A0;Sbit LED2=P0Al;Sbit LED3=P0A2;Sbit LED4=P0A3;SbitKl=PlA0;Sbit K2=P1A1;Sbit K3=P1A2;Sbit K4=P1A3;Void DelayMS(uint x) (Uchar t;Whi
4、le(x-) (For(t=0;t 120;t+);)Void main() (P0=0xFf;Pl=0xff;While(l) (LED1=K1;LED2=K2;If(K3=0) (While(K3=0);LED3=LED3;If(K4=0)While(K4=0);LED4=LED4; DelayMS(lO);2,参考答案:include unsigned char i=O; void delay 10ms() (unsigned int m,n;for(m=0;m 10;m+) for(n=0;n50;n+);void delay()(unsigned int m,n;for(m=0;m5
5、0;m+) for(n=0;n500;n+);)void int 1() interrupt 2(unsigned char reg;EA=0;reg=0x0f&Pl; if(reg=OxOd) delay 10ms(); if(reg=OxOf&Pl) i=l;)else if(reg=0x0e) delay 10ms(); if(reg=OxOf&Pl) i=2;)else if(reg=OxOb) delay 10ms(); if(reg=OxOf&Pl) g;else if(reg=0x07) delay 10ms();if(reg=OxOf&Pl) i=4;)EA=1;void ma
6、in()(unsigned int j,k;Pl_5=0;SP=0x70;EA=1;EX1 = 1;IT1 = 1;for(;)(k=0x01;if(i=0)(for(j=0;j7;j+)(PO二k;delay();k*=2;)for(j=0;j8;j+)(PO二k;delay();k/=2;)if(i=l)(for(j=0;j8;j+) PO=k;delay();k*=2;)if(i=2)(k=0x80;for(j=0;j8;j+)PO=k;delay ();k/=2;)if(i=3)(P0=0x7e;delay();PO=Oxbd;delay();PO=Oxdb;delay();P0=0xe7;delay();)if(i=4)(P0=0xe7;delay();PO=Oxdb;delay();PO=Oxbd;delay();P0=0x7e;delay();)