详见标题,仅供这 Keil C51 v9.60 版官网下载的链接,请自行入坑。并附上这版的 Release Note,但愿这 Release Note 的截图不会造成侵权!也请各位白鼠们自取用,不用谢。
连结于此 ->
C51v9.60 - (95,756K) - (MD5:3C29CCF5B8E7AF3340B3B5C4605CAF6D)
C51 Version 9.60 Release.jpg (577.04 KB, 下载次数: 18)
下载附件
C51 Version 9.60 Release
2019-5-15 12:27 上传
Corrected: in rare cases a signed compare with unsigned char treated the unsigned char as signed. This happens if the unsigned char value results from a calculated assignment. Example:
char i;
unsigned char uc0 = 254;
char c1 = 0;
void main() {
if (c1 <= (uc0 += c1)) // uc0 is wrongly treated signed => -2 therefore the condition (0 <= -2) is false
i = 1;
else
i = 0;
}
Wrong code was generated:
0000 E500 R MOV A,uc0
0002 2500 R ADD A,c1
0004 F500 R MOV uc0,A
0006 D3 SETB C
0007 6480 XRL A,#080H
0009 F8 MOV R0,A |
000A E500 R MOV A,c1 |
000C 6480 XRL A,#080H |
000E 98 SUBB A,R0 |
000F 5004 JNC ?C0001 -> signed char compare
0011 750001 R MOV i,#01H
0014 22 RET
0015 ?C0001:
0015 E4 CLR A
0016 F500 R MOV i,A
0018 ?C0003:
0018 22 RET
The correct code is much longer because according to the C standard a cast to int is necessary:
0000 E500 R MOV A,uc0
0002 2500 R ADD A,c1
0004 FF MOV R7,A
0005 F500 R MOV uc0,A
0007 AD00 R MOV R5,c1
0009 ED MOV A,R5 |
000A 33 RLC A |
000B 95E0 SUBB A,ACC |
000D FC MOV R4,A -> cast of signed char to int
000E D3 SETB C
000F ED MOV A,R5 |
0010 9F SUBB A,R7 |
0011 7480 MOV A,#080H +> implicit cast of unsigned char to int
0013 F8 MOV R0,A |
0014 6C XRL A,R4 |
0015 98 SUBB A,R0 |
0016 5004 JNC ?C0001 -> signed int compare
0018 750001 R MOV i,#01H
001B 22 RET
001C ?C0001:
001C E4 CLR A
001D F500 R MOV i,A
001F ?C0003:
001F 22 RET
To generate smaller code the signedness of the values to be compared should be the same:
...
if ((unsigned char)c1 <= (uc0 += c1))
...
0000 E500 R MOV A,uc0
0002 2500 R ADD A,c1
0004 FF MOV R7,A
0005 F500 R MOV uc0,A
0007 E500 R MOV A,c1
0009 D3 SETB C
000A 9F SUBB A,R7 |
000B 5004 JNC ?C0001 -> unsigned char compare
000D 750001 R MOV i,#01H
0010 22 RET
0011 ?C0001:
0011 E4 CLR A
0012 F500 R MOV i,A
0014 ?C0003:
0014 22 RET
你让Arduino情何以堪。。
uV2选择正确的字体和编码,中文一点问题都没有
一周热门 更多>