From: SourceForge.net <no...@so...> - 2005-06-28 22:00:54
|
Bugs item #1229346, was opened at 2005-06-29 10:00 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=1229346&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: pic14 target Group: None Status: Open Resolution: None Priority: 5 Submitted By: Simon (smcauliffe) Assigned to: Nobody/Anonymous (nobody) Summary: Array and temporary bugs Initial Comment: Here's a small snippet of code that reproduces two simple bugs. Sorry if this has already been reported, I couldn't find the information elsewhere though. #define __16f627 #include <pic/pic16f627.h> unsigned char buffer[16]; int main() { if (buffer[0] == 0) { PORTA = buffer[1]; } if (buffer[0] == 1) { PORTA = buffer[2]; } return 0; } The first bug is caused by having two if statements (or a switch statement). It causes a temporary to be allocated but nothing is ever assigned to the temporary variable. Having only one if statement doesn't allocate a temporary and then it works. The second bug is PORTA not being assigned. If assigning a constant, it works fine, but assigning from the array results in no code. The resulting assembly is below (slightly edited for brevity): ;entry: _main ;Function start ;2 compiler assigned registers: ; r0x21 ; s0x7F _main ;Function start ; if (buffer[0] == 0) { 000005 1283 bcf 0x3, 0x5 BANKSEL r0x21 000006 1703 bsf 0x3, 0x6 000007 0830 movf 0x30, w MOVF r0x21,W 000008 1d03 btfss 0x3, 0x2 BTFSS STATUS,2 000009 280a goto 0xa GOTO _00106_DS_ _00106_DS_ ; if (buffer[0] == 1) { 00000a 0b30 decfsz 0x30, w DECFSZ r0x21,W 00000b 280c goto 0xc GOTO _00108_DS_ _00108_DS_ ; return 0; 00000c 3000 movlw 0 MOVLW 0x00 00000d 00ff movwf 0x7f MOVWF s0x7F 00000e 3000 movlw 0 MOVLW 0x00 00000f 0008 return RETURN At address 7, the temporary is being used, but hasn't yet been assigned to from buffer[0] And also, as you can see, there is no mention of assigning to PORTA (there would be if it was a constant assignment). Perhaps it's being optimised away? In any case, I hope these are useful. Please drop me an email at S.M...@dt... if I can provide any furtherr information or if I can be of any assistance in debugging the compiler. Thanks. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1229346&group_id=599 |
From: SourceForge.net <no...@so...> - 2005-07-01 02:10:37
|
Bugs item #1229346, was opened at 2005-06-28 22:00 Message generated for change (Settings changed) made by tecodev You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1229346&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: pic14 target >Group: fixed >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Simon (smcauliffe) >Assigned to: Raphael Neider (tecodev) Summary: Array and temporary bugs Initial Comment: Here's a small snippet of code that reproduces two simple bugs. Sorry if this has already been reported, I couldn't find the information elsewhere though. #define __16f627 #include <pic/pic16f627.h> unsigned char buffer[16]; int main() { if (buffer[0] == 0) { PORTA = buffer[1]; } if (buffer[0] == 1) { PORTA = buffer[2]; } return 0; } The first bug is caused by having two if statements (or a switch statement). It causes a temporary to be allocated but nothing is ever assigned to the temporary variable. Having only one if statement doesn't allocate a temporary and then it works. The second bug is PORTA not being assigned. If assigning a constant, it works fine, but assigning from the array results in no code. The resulting assembly is below (slightly edited for brevity): ;entry: _main ;Function start ;2 compiler assigned registers: ; r0x21 ; s0x7F _main ;Function start ; if (buffer[0] == 0) { 000005 1283 bcf 0x3, 0x5 BANKSEL r0x21 000006 1703 bsf 0x3, 0x6 000007 0830 movf 0x30, w MOVF r0x21,W 000008 1d03 btfss 0x3, 0x2 BTFSS STATUS,2 000009 280a goto 0xa GOTO _00106_DS_ _00106_DS_ ; if (buffer[0] == 1) { 00000a 0b30 decfsz 0x30, w DECFSZ r0x21,W 00000b 280c goto 0xc GOTO _00108_DS_ _00108_DS_ ; return 0; 00000c 3000 movlw 0 MOVLW 0x00 00000d 00ff movwf 0x7f MOVWF s0x7F 00000e 3000 movlw 0 MOVLW 0x00 00000f 0008 return RETURN At address 7, the temporary is being used, but hasn't yet been assigned to from buffer[0] And also, as you can see, there is no mention of assigning to PORTA (there would be if it was a constant assignment). Perhaps it's being optimised away? In any case, I hope these are useful. Please drop me an email at S.M...@dt... if I can provide any furtherr information or if I can be of any assistance in debugging the compiler. Thanks. ---------------------------------------------------------------------- >Comment By: Raphael Neider (tecodev) Date: 2005-07-01 02:10 Message: Logged In: YES user_id=1115835 Both bugs have been fixed in SDCC 2.5.1 #1053. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1229346&group_id=599 |