??? 06/14/07 07:41 Modified: 06/14/07 07:51 Read: times |
#140743 - teaching the compiler... Responding to: ???'s previous message |
Christoph,
this is exactly what I consider absolutely unnecessary (even harmful) - to modify the C code so that it compiles into effective (in any way) binary - unless you are the compiler maker. Just for the record, the same line compiles into 21 bytes in SDCC: 018F AA 82 458 mov r2,dpl 0191 7B 07 461 mov r3,#0x07 0193 462 00101$: 0193 ED 466 mov a,r5 0194 2D 468 add a,r5 0195 FC 469 mov r4,a 0196 74 01 471 mov a,#0x01 0198 5A 472 anl a,r2 0199 4C 474 orl a,r4 019A FD 475 mov r5,a 019B EA 479 mov a,r2 019C C3 480 clr c 019D 13 481 rrc a 019E FA 482 mov r2,a 019F DB F2 486 djnz r3,00101$ 01A1 8D 82 490 mov dpl,r5 01A3 22 492 ret ... and the following spares 2 more bytes, yielding 19 bytes: UC r,i=7;DO{r+=r+(c&1);c/=2;}WH(--i);RT r; 018F AA 82 458 mov r2,dpl 0191 7B 07 461 mov r3,#0x07 0193 462 00101$: 0193 74 01 464 mov a,#0x01 0195 5A 465 anl a,r2 0196 2C 468 add a,r4 0197 2C 471 add a,r4 0198 FC 472 mov r4,a 0199 EA 476 mov a,r2 019A C3 477 clr c 019B 13 478 rrc a 019C FA 479 mov r2,a 019D DB F4 483 djnz r3,00101$ 019F 8C 82 487 mov dpl,r4 01A1 22 489 ret(but in Keil's makes again that stupid assumption that r cannot be in register, so it is less effective there). JW PS. would not be those stupid "features" in those two compilers, UC r,i=1;DO{r+=r+(c&i);}WH(i+=i);RT r;would have even more potential to be the best binary-size-wise... |