From: SourceForge.net <no...@so...> - 2006-04-24 21:03:34
|
Feature Requests item #1475742, was opened at 2006-04-24 21:25 Message generated for change (Comment added) made by bernhardheld You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=350599&aid=1475742&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. >Category: None >Group: None >Status: Open >Priority: 3 Submitted By: Stevie Oh (stevie-o) >Assigned to: Bernhard Held (bernhardheld) Summary: Braindead bit-test handling with == 0 Initial Comment: I apologize in advance if this should really be a feature request/enhancement. ==Summary== The translation of a single-bit test to a BTFSS/BTFSC instruction is not all that smart: ; .line 9; btfssdumb.c if (!(PORTB & BIT_5)) { foo(); } BTFSC _PORTB, 5 GOTO _00106_DS_ CALL _foo That works fine. But this perfectly valid alternate syntax fails miserably: ; .line 10; btfssdumb.c if ((PORTB & BIT_5) == 0) { bar(); } MOVLW 0x20 ANDWF _PORTB, W MOVWF r0x00 MOVF r0x00, W BNZ _00114_DS_ GOTO _00115_DS_ ==SDCC Version== SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.5.6 #1249 (Apr 17 2006) (MINGW32) ==Command Line== sdcc -mpic16 -p18f452 btfssdumb.c ==Other Information== Attached is a tar.bz2 of all the files involved. ---------------------------------------------------------------------- >Comment By: Bernhard Held (bernhardheld) Date: 2006-04-24 23:03 Message: Logged In: YES user_id=203539 Well, the code could be even more worse ;-) Obviously the promotion to int has been suppressed. At the moment sdcc compares two 'unsigned char'. It's not that easy to fit the promotion rules and bit banging together, but I see a chance to optimize this case. Let's make a feature request out of it. ---------------------------------------------------------------------- Comment By: Raphael Neider (tecodev) Date: 2006-04-24 22:32 Message: Logged In: YES user_id=1115835 I am no expert in these questions (ask Bernhard Held ;-)), but this should be due to the all-famous C promotion rules: Comparing a bit(field) and an integer probably requires an upcast to int (at least to char it seems), so... This will not be fixed (unless I am proven wrong, that is). Regards, Raphael ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=350599&aid=1475742&group_id=599 |