From: Sandeep D. <sa...@wi...> - 2001-11-07 23:34:42
|
Alex, This could happen when the register pressure is high.. I think you need the complex example (if you simplify the problem will go away). I sounds like two iTemps are sharing the same registers. Sandeep > -----Original Message----- > From: sdc...@li... > [mailto:sdc...@li...]On Behalf Of > no...@so... > Sent: Tuesday, November 06, 2001 10:12 PM > To: no...@so... > Subject: [sdcc-devel] [ sdcc-Bugs-479001 ] Code gen > overwrites registers > > > Bugs item #479001, was opened at 2001-11-06 22:12 > You can respond by visiting: > http://sourceforge.net/tracker/?func=detail&atid=100599&aid=47 > 9001&group_id=599 > > Category: msc51(8051) target > Group: None > Status: Open > Resolution: None > Priority: 5 > Submitted By: Alex Karahalios (karahalios) > Assigned to: Nobody/Anonymous (nobody) > Summary: Code gen overwrites registers > > Initial Comment: > The following problem occurs with all versions of SDCC, > although this simply test case does not fail with the latest > version in CVS. I haven't been able to simplify my more > complex program yet. > > The following C code: > > extern char Data1[]; > > extern int f1(void); > extern void f2(char *,int); > > void main(void) { > int l; > > l = f1(); > f2(&Data1,l+10); > } > > generates the follow ASM code > > ; bug.c 9 > lcall _f1 > mov r2,dpl > mov r3,dph > ; bug.c 10 > mov r2,#_Data1 > ; Peephole 3.c changed mov to clr > clr a > mov r3,a > mov r4,a > mov a,#0x0A > add a,r2 > mov _f2_PARM_2,a > ; Peephole 180 changed mov to clr > clr a > addc a,r3 > mov (_f2_PARM_2 + 1),a > mov dpl,r2 > mov dph,r3 > mov b,r4 > lcall _f2 > > Notice that after the call to _f1, the results are stored in > r2&r3. Immediately afterwards r2&r3 are overwritten. Later on > before the call to _f2, r2&r3 are used, but have since been > destroyed. > > As I mentioned, this simple test case does not currently fail > with the current CVS version, but my large program still does. > > The current work around is to rewrite the C code so that > function parameters are precalculated before being used: > > l = f1()+10; > f2(&Data1,l); > > Thanks, > > Alex Karahalios > > > > ---------------------------------------------------------------------- > > You can respond by visiting: > http://sourceforge.net/tracker/?func=detail&atid=100599&aid=47 9001&group_id=599 _______________________________________________ sdcc-devel mailing list sdc...@li... https://lists.sourceforge.net/lists/listinfo/sdcc-devel |