From: SourceForge.net <no...@so...> - 2004-06-04 13:18:07
|
Bugs item #966505, was opened at 2004-06-04 06:18 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=966505&group_id=599 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: SDCC MCS51 code generation bug 2 Initial Comment: I has found several mistakes in SDCC: Source: #include <8052.h> #define HL0 P0_0 #define HL1 P0_1 unsigned char test; void test1(unsigned char arg) { switch (arg) { case 0: { HL0=1; HL1=1; break; } case 1: { HL0=0; HL1=0; break; } case 2: { HL0=1; HL1=0; break; } } } void main(void) { test1(0); } SDCC run command: sdcc --verbose --model-small --peep-asm -mmcs51 -- iram-size 256 --xram-size 0 --code-size 12288 --nojtbound test.c SDCC version: SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51 /ds400/hc08 2.4.1 (Jun 3 2004) (MINGW32) Asm list: 353 ;test.c:8: void test1(unsigned char arg) 354 ; --------------------------- -------------- 355 ; function test1 356 ; --------------------------- -------------- 0031 357 _test1: 0002 358 ar2 = 0x02 0003 359 ar3 = 0x03 0004 360 ar4 = 0x04 0005 361 ar5 = 0x05 0006 362 ar6 = 0x06 0007 363 ar7 = 0x07 0000 364 ar0 = 0x00 0001 365 ar1 = 0x01 366 ; genReceive 367 ;test.c:10: switch (arg) 368 ; genJumpTab 369 ; Peephole 244.a moving first to a instead of r2 0031 E5 82 370 mov a,dpl 0033 FA 371 mov r2,a 0034 25 E0 372 add a,acc 0036 2A 373 add a,r2 0037 90s00r3B 374 mov dptr,#00108$ 003A 73 375 jmp @a+dptr 003B 376 00108$: 003B 02s00r47 377 ljmp 00101$ 003E 02s00r4D 378 ljmp 00102$ 0041 02s00r53 379 ljmp 00103$ 0044 02s00r58 380 ljmp 00104$ 381 ;test.c:12: case 0: 0047 382 00101$: 383 ;test.c:14: HL0=1; 384 ; genAssign 0047 D2 80 385 setb _P0_0 386 ;test.c:15: HL1=1; 387 ; genAssign 0049 D2 81 388 setb _P0_1 389 ;test.c:16: break; 390 ;test.c:18: case 1: 391 ; Peephole 112.b changed ljmp to sjmp 004B 80 0F 392 sjmp 00106 $ <=========== peephole 251.b is absent! 004D 393 00102$: 394 ;test.c:20: HL0=0; 395 ; genAssign 004D C2 80 396 clr _P0_0 397 ;test.c:21: HL1=0; 398 ; genAssign 004F C2 81 399 clr _P0_1 400 ;test.c:22: break; 401 ;test.c:24: case 2: 402 ; Peephole 112.b changed ljmp to sjmp 0051 80 09 403 sjmp 00106 $ <=========== peephole 251.b is absent! 0053 404 00103$: 405 ;test.c:26: HL0=1; 406 ; genAssign 0053 D2 80 407 setb _P0_0 408 ;test.c:27: HL1=0; 409 ; genAssign 0055 C2 81 410 clr _P0_1 411 ;test.c:28: break; 412 ;test.c:30: case 3: 413 ; Peephole 112.b changed ljmp to sjmp 414 ; Peephole 251.b replaced sjmp to ret with ret <=== OK! 0057 22 415 ret 0058 416 00104$: 417 ;test.c:32: HL0=0; 418 ; genAssign 0058 C2 80 419 clr _P0_0 420 ;test.c:33: HL1=1; 421 ; genAssign 005A D2 81 422 setb _P0_1 423 ;test.c:36: } 005C 424 00106$: 005C 22 425 ret ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=966505&group_id=599 |