汇编不会写 仿照999改了个99:59的倒数计时器 也没用keil 课上一直只讲汇编 生成hex装载单片机在proteus仿真 结果也不对 我也不知道从何下手改程序 求大神帮改改程序!或者有汇编版的倒数计时器带注释能看懂的share一下也行!不知道咱们这里可不可以悬赏!
单片机源程序如下:
- #include <reg51.h>
- sbit RCK=P1^7;
- sbit K1=P1^6;
- sbit K2=P1^5;
- sbit K3=P1^4;
- bit K0=0;
- unsigned char ms05=0;
- unsigned int s=0;
- unsigned char code c[10]=
- {0x03,0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x09};
- void disp4();
- void up()
- {
- unsigned char n=0;
- unsigned int t;
- if(s!=9959)s++;
- else s=0;
- disp4();
- for(t=0;t<2000;t++);
- while (K2==0){
- for(t=0;t<2000;t++)
- n++;
- if (n==10){ n=9;
- if (s!=999)s++;
- else s=0;
- disp3();}}
- }
- void down()
- {
- unsigned char n=0;
- unsigned int t;
- if(s!=0)s--;
- else s=999;
- disp3();
- for(t=0;t<20000;t++);
- while (K3==0){
- for(t=0;t<2000;t++)
- n++;
- if (n==10){ n=9;
- if (s!=0)s--;
- else s=999;
- disp4();}}
- }
- void main()
- {
- TMOD=0x02;
- SCON=0;
- TH0=0x06;TL0=0x06;
- IP=0x01;
- IT0=1;
- IE=0x83;
- disp4();
- while(1){
- while(K1==1);
- if((K2==0)&(K3!=0))
- up();
- if((K3==0)&(K2!=0))
- down();}
- }
- void t0()interrupt 1{
- ms05++;
- if(ms05==200){ms05=0;
- if(s!=0)s--;
- else{s=0;
- TR0=0;}
- disp4();}}
- void int0()interrupt 0{
- if(K1!=0){
- K0=!K0;
- if(K0==1)TR0=1;
- else TR0=0;}
- }
复制代码 |