很明显,if参与了代码,逻辑有问题
无端的多出了这些代码: SJMP C:0009 DJNZ NOPBUF(0x08),C:0006 少于4的虽然逻辑对了,但多执行一个SJMP(2周期) 4个周期以上的还是对的
a只能作为常量,做变量用的话所有语句都会被理解成程序,全部参与编译,全乱套了
15: void main(void) 16: { 17: unsigned char i; 18: __NOPX__(1); C:0x0003 00 NOP C:0x0004 8003 SJMP C:0009 C:0x0006 D508FD DJNZ NOPBUF(0x08),C:0006 19: P1_1=~P1_1; C:0x0009 B291 CPL P1_1(0x90.1) 20: __NOPX__(2); C:0x000B E4 CLR A C:0x000C F508 MOV NOPBUF(0x08),A C:0x000E 8003 SJMP C:0013 C:0x0010 D508FD DJNZ NOPBUF(0x08),C:0010 21: P1_1=~P1_1; C:0x0013 B291 CPL P1_1(0x90.1) 22: __NOPX__(3); C:0x0015 00 NOP C:0x0016 E4 CLR A C:0x0017 F508 MOV NOPBUF(0x08),A C:0x0019 8003 SJMP C:001E C:0x001B D508FD DJNZ NOPBUF(0x08),C:001B 23: P1_1=~P1_1; C:0x001E B291 CPL P1_1(0x90.1) 24: __NOPX__(4); C:0x0020 750801 MOV NOPBUF(0x08),#0x01 C:0x0023 D508FD DJNZ NOPBUF(0x08),C:0023 25: P1_1=~P1_1; C:0x0026 B291 CPL P1_1(0x90.1) 26: __NOPX__(5); C:0x0028 00 NOP C:0x0029 750801 MOV NOPBUF(0x08),#0x01 C:0x002C D508FD DJNZ NOPBUF(0x08),C:002C 27: P1_1=~P1_1; C:0x002F B291 CPL P1_1(0x90.1) 28: __NOPX__(6); C:0x0031 750802 MOV NOPBUF(0x08),#0x02 C:0x0034 D508FD DJNZ NOPBUF(0x08),C:0034 29: P1_1=~P1_1; C:0x0037 B291 CPL P1_1(0x90.1) 30: __NOPX__(7); C:0x0039 00 NOP C:0x003A 750802 MOV NOPBUF(0x08),#0x02 C:0x003D D508FD DJNZ NOPBUF(0x08),C:003D 31: P1_1=~P1_1; C:0x0040 B291 CPL P1_1(0x90.1) 32: __NOPX__(8); C:0x0042 750803 MOV NOPBUF(0x08),#0x03 C:0x0045 D508FD DJNZ NOPBUF(0x08),C:0045 33: P1_1=~P1_1; C:0x0048 B291 CPL P1_1(0x90.1) 34: __NOPX__(9); C:0x004A 00 NOP C:0x004B 750803 MOV NOPBUF(0x08),#0x03 C:0x004E D508FD DJNZ NOPBUF(0x08),C:004E 35: __NOPX__(10); C:0x0051 750804 MOV NOPBUF(0x08),#0x04 C:0x0054 D508FD DJNZ NOPBUF(0x08),C:0054 36: __NOPX__(11); C:0x0057 00 NOP C:0x0058 750804 MOV NOPBUF(0x08),#0x04 C:0x005B D508FD DJNZ NOPBUF(0x08),C:005B 37: __NOPX__(12); C:0x005E 750805 MOV NOPBUF(0x08),#0x05 C:0x0061 D508FD DJNZ NOPBUF(0x08),C:0061 38: __NOPX__(100); C:0x0064 750831 MOV NOPBUF(0x08),#0x31 C:0x0067 D508FD DJNZ NOPBUF(0x08),C:0067 39: __NOPX__(111); C:0x006A 00 NOP C:0x006B 750836 MOV NOPBUF(0x08),#0x36 C:0x006E D508FD DJNZ NOPBUF(0x08),C:006E 40: while(1) 41: { 42: __NOPX__(i); C:0x0071 E509 MOV A,0x09 C:0x0073 30E001 JNB 0xE0.0,C:0077 C:0x0076 00 NOP C:0x0077 E509 MOV A,0x09 C:0x0079 D3 SETB C C:0x007A 9401 SUBB A,#0x01 C:0x007C 4006 JC C:0084 C:0x007E E509 MOV A,0x09 C:0x0080 13 RRC A C:0x0081 14 DEC A C:0x0082 F508 MOV NOPBUF(0x08),A C:0x0084 E509 MOV A,0x09 C:0x0086 D3 SETB C C:0x0087 9403 SUBB A,#0x03 C:0x0089 4003 JC C:008E C:0x008B D508FD DJNZ NOPBUF(0x08),C:008B 43: i++; C:0x008E 0509 INC 0x09 44: } C:0x0090 80DF SJMP C:0071 |