From: SourceForge.net <no...@so...> - 2004-09-17 00:37:14
|
Bugs item #1028702, was opened at 2004-09-15 20:36 Message generated for change (Comment added) made by vrokas You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1028702&group_id=599 Category: pic16 target >Group: fixed >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: ccsporters (tecodev) >Assigned to: Vangelis Rokas (vrokas) Summary: PIC16: shift left fails Initial Comment: The following piece of code fails: #pragma stack 0x100 60 char test(char target) { return (1 << target); } int main() { return test(4); } This is compiled into: _test: #LINE 2; shifttest.c char test(char target) { MOVFF FSR2L, POSTDEC1 MOVFF FSR1L, FSR2L MOVFF r0x2E, POSTDEC1 [1] MOVWF r0x2E #LINE 3; shifttest.c return (1 << target); [2] MOVF 0x01, W [3] MOVWF r0x2E COMF r0x2E, W RRCF r0x2E, F First problem (liveranges?): [1]: Argument "target" is placed in r0x2E, [3]: literal (!) 0x01 overwrites our argument... Second problem: [2]: a literal 0x01 is to be stored in WREG, but register 0x01 is copied instead This problem might be caused by gen.c:8603: pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(left),offset)); By replacing POC_MOVFW with POC_MOVLW this second problem disappears. (But if this is correct in general, we do not know...) Everything done with SDCC pic16 2.4.4 #840 (Sep 13 2004) (UNIX). Greetings, Raphael Neider & Daniel Winkler ---------------------------------------------------------------------- >Comment By: Vangelis Rokas (vrokas) Date: 2004-09-17 03:37 Message: Logged In: YES user_id=770505 Bug fixed in SDCC v.2.4.4 #843 . Code generator function for shift left did not inherently support cases where result and right (shift count) shared the same registers. Problem solved by modifying register allocator to always allocate different registers for result and right (and possibly left... but this needs extra optimization, work for the future! ... ) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1028702&group_id=599 |