From: Kustaa N. <Kus...@pl...> - 2014-06-23 04:00:30
|
Hi I'm trying to optimise a critical section of my code and to get rid of the BANKSEL instructions I would like to place variables on the same bank. I tried: #pragma udata bank2 COUNTER NCO SPEED OLDV char COUNTER; short NCO; short SPEED; short OLDV; ... NCO += SPEED; ... But this compiles to: 06931 ; .line 91; stepperirq.c NCO += SPEED; 00003E 51?? 06932 MOVF _SPEED, W, B 000040 ???? 06933 BANKSEL _NCO 000042 27?? 06934 ADDWF _NCO, F, B 000044 ???? 06935 BANKSEL (_SPEED + 1) 000046 51?? 06936 MOVF (_SPEED + 1), W, B 000048 ???? 06937 BANKSEL (_NCO + 1) 00004A 23?? 06938 ADDWFC (_NCO + 1), F, B so there are three BANKSEL instructions, all of which are basically unnecessary as the correct bank was already chose in the previous code (not shown). I do see a bunch of 06686 ; removed redundant BANKSEL so obviously sometimes the compiler knows to remove redundant BANKSELs, but what do I need to do 'help' it to do in this case? br Kusti This e-mail may contain confidential or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. We will not be liable for direct, indirect, special or consequential damages arising from alteration of the contents of this message by a third party or as a result of any virus being passed on or as of transmission of this e-mail in general. |
From: Raphael N. <rn...@we...> - 2014-06-23 04:14:17
|
Hi, I would have to look at the compiler's source code for details. What should work is to group the variables into a structure like struct { char counter; short NCO; short SPEED; short OLDV; /*... */ } grp; and to access them via grp .NCO += grp.SPEED; You could of course introduce macros to hide the structure access like #define NCO grp.NCO ... after declaring/defining the struct. Hope that helps, Raphael On Jun 23, 2014 6:01 AM, "Kustaa Nyholm" <Kus...@pl...> wrote: > Hi > > I'm trying to optimise a critical section of my code > and to get rid of the BANKSEL instructions I would > like to place variables on the same bank. > > I tried: > > #pragma udata bank2 COUNTER NCO SPEED OLDV > char COUNTER; > short NCO; > short SPEED; > short OLDV; > ... > > NCO += SPEED; > ... > > > > But this compiles to: > > 06931 ; .line 91; stepperirq.c NCO += > SPEED; > 00003E 51?? 06932 MOVF _SPEED, W, B > 000040 ???? 06933 BANKSEL _NCO > 000042 27?? 06934 ADDWF _NCO, F, B > 000044 ???? 06935 BANKSEL (_SPEED + 1) > 000046 51?? 06936 MOVF (_SPEED + 1), W, B > 000048 ???? 06937 BANKSEL (_NCO + 1) > 00004A 23?? 06938 ADDWFC (_NCO + 1), F, B > > so there are three BANKSEL instructions, all of which are basically > unnecessary as the correct bank was already chose in the previous > code (not shown). > > I do see a bunch of > > 06686 ; removed redundant BANKSEL > > > so obviously sometimes the compiler knows to remove redundant BANKSELs, > but what do I need to do 'help' it to do in this case? > > br Kusti > > > > > > This e-mail may contain confidential or privileged information. If you are > not the intended recipient (or have received this e-mail in error) please > notify the sender immediately and destroy this e-mail. Any unauthorized > copying, disclosure or distribution of the material in this e-mail is > strictly forbidden. We will not be liable for direct, indirect, special or > consequential damages arising from alteration of the contents of this > message by a third party or as a result of any virus being passed on or as > of transmission of this e-mail in general. > > > ------------------------------------------------------------------------------ > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions > Find What Matters Most in Your Big Data with HPCC Systems > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. > Leverages Graph Analysis for Fast Processing & Easy Data Exploration > http://p.sf.net/sfu/hpccsystems > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > |
From: Kustaa N. <Kus...@pl...> - 2014-06-23 04:23:04
|
Brilliant, that did the trick! I can work with that as anyway most of the variable are in an array (with compile time knows indexes) of structs anyway so I need to just wrap all variables in in struct. Of course it would be nice and logical if the compiler had understood that the variables are in the same bank in this situation. Many thanks for your help. br Kusti From: "rn...@we...<mailto:rn...@we...>" <rn...@we...<mailto:rn...@we...>> Reply-To: "sdc...@li...<mailto:sdc...@li...>" <sdc...@li...<mailto:sdc...@li...>> Date: Mon, 23 Jun 2014 07:14:09 +0300 To: "sdc...@li...<mailto:sdc...@li...>" <sdc...@li...<mailto:sdc...@li...>> Subject: Re: [Sdcc-user] PIC forcing variables to be on the same bank struct { char counter; short NCO; short SPEED; short OLDV; /*... */ } grp; ________________________________ This e-mail may contain confidential or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. We will not be liable for direct, indirect, special or consequential damages arising from alteration of the contents of this message by a third party or as a result of any virus being passed on or as of transmission of this e-mail in general. |
From: Gál Z. <tra...@fr...> - 2014-06-23 20:14:05
|
Hello Raphael, This was new for me also. It would worth to write about it in the sdcc manual. Regards, Zsolt |