缘由小容量的单片机芯片怎么提高存储空间利用率? - 24小时必答区 https://bbs.csdn.net/topics/600865890
#include "reg52.h"
sbit k=P2^0;
void main()
{unsigned char a=0,xd=0;while(1){if(k==0&&++xd==0){++a;while(k==0);}if(a==1)P0=~1;else if(a==2)P0=~3;else if(a==3)P0=~2;else {P0=255;a=0;}}
}
#include "reg52.h"
sbit k=P2^0;
unsigned char led[]={0,1,3,2};
void main()
{unsigned char a=0,xd=0;while(1){if(k==0&&++xd==0){++a;while(k==0);}if(a>=4)a=0;P0=~led[a];}
}
#include "reg52.h"
sbit k=P2^0;
unsigned char led[]={0,1,3,2};
void main()
{unsigned char a=0,xd=0;while(1){if(k==0&&++xd==0){++a;while(k==0);}if(a==4)a=0;P0=~led[a];}
}
#include "reg52.h"
sbit k=P2^0;
void main()
{unsigned char a=0,xd=0;while(1){if(k==0&&++xd==0){++a;while(k==0);}switch(a){case 0x01: P3 = 1; break;case 0x02: P3 = 3; break;case 0x03: P3 = 2; break;default: P3 = 0; a = 0; break;}}
}
C:0x0000 020032 LJMP C:0032main:
C:0x0003 E4 CLR A
C:0x0004 FF MOV R7,A
C:0x0005 FE MOV R6,A
C:0x0006 20A008 JB k(0xA0.0),C:0011
C:0x0009 0E INC R6
C:0x000A EE MOV A,R6
C:0x000B 7004 JNZ C:0011
C:0x000D 0F INC R7
C:0x000E 30A0FD JNB k(0xA0.0),C:000E
C:0x0011 EF MOV A,R7
C:0x0012 24FE ADD A,#0xFE
C:0x0014 600C JZ C:0022
C:0x0016 14 DEC A
C:0x0017 600E JZ C:0027
C:0x0019 2402 ADD A,#0x02
C:0x001B 700F JNZ C:002C
C:0x001D 75B001 MOV P3(0xB0),#0x01
C:0x0020 80E4 SJMP C:0006
C:0x0022 75B003 MOV P3(0xB0),#0x03
C:0x0025 80DF SJMP C:0006
C:0x0027 75B002 MOV P3(0xB0),#0x02
C:0x002A 80DA SJMP C:0006
C:0x002C E4 CLR A
C:0x002D F5B0 MOV P3(0xB0),A
C:0x002F FF MOV R7,A
C:0x0030 80D4 SJMP C:0006
C:0x0032 787F MOV R0,#0x7F
C:0x0034 E4 CLR A
C:0x0035 F6 MOV @R0,A
C:0x0036 D8FD DJNZ R0,C:0035
C:0x0038 758107 MOV SP(0x81),#0x07
C:0x003B 020003 LJMP main(C:0003)
Program Size: data=9.0 xdata=0 code=71
Program Size: data=13.0 xdata=0 code=186
Program Size: data=13.0 xdata=0 code=180
Program Size: data=9.0 xdata=0 code=62