---------------------------------------------------------------- Gabriel Fernandez
On Feb 20, 2010, at 6:08 PM, mspgcc-users-requ...@lists.sourceforge.net wrote: > Send Mspgcc-users mailing list submissions to > mspgcc-users@lists.sourceforge.net > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/mspgcc-users > or, via email, send a message with subject or body 'help' to > mspgcc-users-requ...@lists.sourceforge.net > > You can reach the person managing the list at > mspgcc-users-ow...@lists.sourceforge.net > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Mspgcc-users digest..." > > > Today's Topics: > > 1. Re: stack variable in flash? (Wayne Uroda) > 2. Re: stack variable in flash? (c...@turner.ca) > 3. Re: stack variable in flash? (N. Coesel) > 4. Re: stack variable in flash? (Tadashi G. Takaoka) > 5. Re: stack variable in flash? (Carl) > 6. Re: stack variable in flash? (N. Coesel) > 7. Re: stack variable in flash? (c...@turner.ca) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 20 Feb 2010 01:35:03 +0000 > From: "Wayne Uroda" <wayne.ur...@grabba.com> > Subject: Re: [Mspgcc-users] stack variable in flash? > To: "GCC for MSP430 - http://mspgcc.sf.net" > <mspgcc-users@lists.sourceforge.net> > Message-ID: > > <1628222763-1266629704-cardhu_decombobulator_blackberry.rim.net-5483999...@bda001.bisx.prodap.on.blackberry> > > Content-Type: text/plain > > try declaring i as volatile, or the compiler will probably get rid of it > since it has no effect or side-effect. > Sent via BlackBerry from Vodafone > > -----Original Message----- > From: Carl <c...@turner.ca> > Date: Fri, 19 Feb 2010 18:29:03 > To: <mspgcc-users@lists.sourceforge.net> > Subject: [Mspgcc-users] stack variable in flash? > > I'm sure that I'm missing some basic here but I'm not sure what. The > first variable on the stack is in an unexpected location. I would expect > it to be located somewhere on the stack in RAM (0x30ff-0x1100) but it is > located in flash memory and it does not get set or incremented. > > > #include <io.h> > > int main() > { > int i=0; > while(1) > i++; > } > > msp430-gcc -g -O0 -mmcu=msp430x2618 -I/opt/msp430/4.4.2/include main.c > > (gdb) load a.out > Loading section .text, size 0x46 lma 0x3100 > Loading section .vectors, size 0x40 lma 0xffc0 > Start address 0x3100, load size 134 > Transfer rate: 1 KB/sec, 33 bytes/write. > (gdb) c > Continuing. > ^C > Program received signal SIGINT, Interrupt. > main () at main.c:7 > 7 i++; > (gdb) p &i > $1 = (int *) 0x3102 > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users > > ------------------------------ > > Message: 2 > Date: Fri, 19 Feb 2010 19:43:06 -0800 > From: <c...@turner.ca> > Subject: Re: [Mspgcc-users] stack variable in flash? > To: wayne.ur...@grabba.com, "GCC for MSP430 - http://mspgcc.sf.net" > <mspgcc-users@lists.sourceforge.net> > Message-ID: <web-68073...@redback.webnames.ca> > Content-Type: text/plain;charset=utf-8 > > I tried declaring as volatile and it is at the exact same address. > > Carl > > On Sat, 20 Feb 2010 01:35:03 +0000 > "Wayne Uroda" <wayne.ur...@grabba.com> wrote: >> try declaring i as volatile, or the compiler will probably get rid of it >> since it has no effect or side-effect. >> Sent via BlackBerry from Vodafone >> >> -----Original Message----- >> From: Carl <c...@turner.ca> >> Date: Fri, 19 Feb 2010 18:29:03 >> To: <mspgcc-users@lists.sourceforge.net> >> Subject: [Mspgcc-users] stack variable in flash? >> >> I'm sure that I'm missing some basic here but I'm not sure what. The >> first variable on the stack is in an unexpected location. I would expect >> it to be located somewhere on the stack in RAM (0x30ff-0x1100) but it is >> located in flash memory and it does not get set or incremented. >> >> >> #include <io.h> >> >> int main() >> { >> int i=0; >> while(1) >> i++; >> } >> > > > > ------------------------------ > > Message: 3 > Date: Sat, 20 Feb 2010 09:08:18 +0100 > From: "N. Coesel" <n...@nctdev.nl> > Subject: Re: [Mspgcc-users] stack variable in flash? > To: "GCC for MSP430 - > http://mspgcc.sf.net"<mspgcc-users@lists.sourceforge.net> > Message-ID: <3.0.5.32.20100220090818.0122c...@192.168.2.20> > Content-Type: text/plain; charset="us-ascii" > > Carl, > > Try to declare it outside the function (as a global). > > At 19:43 19-2-2010 -0800, you wrote: >> I tried declaring as volatile and it is at the exact same address. >> >> Carl >> >> On Sat, 20 Feb 2010 01:35:03 +0000 >> "Wayne Uroda" <wayne.ur...@grabba.com> wrote: >>> try declaring i as volatile, or the compiler will probably get rid of it > since it has no effect or side-effect. >>> Sent via BlackBerry from Vodafone >>> >>> -----Original Message----- >>> From: Carl <c...@turner.ca> >>> Date: Fri, 19 Feb 2010 18:29:03 >>> To: <mspgcc-users@lists.sourceforge.net> >>> Subject: [Mspgcc-users] stack variable in flash? >>> >>> I'm sure that I'm missing some basic here but I'm not sure what. The >>> first variable on the stack is in an unexpected location. I would expect >>> it to be located somewhere on the stack in RAM (0x30ff-0x1100) but it is >>> located in flash memory and it does not get set or incremented. >>> >>> >>> #include <io.h> >>> >>> int main() >>> { >>> int i=0; >>> while(1) >>> i++; >>> } >>> >> >> --------------------------------------------------------------------------- > --- >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Mspgcc-users mailing list >> Mspgcc-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/mspgcc-users >> >> > > > > ------------------------------ > > Message: 4 > Date: Sat, 20 Feb 2010 17:53:07 +0900 > From: "Tadashi G. Takaoka" <t...@method.jp> > Subject: Re: [Mspgcc-users] stack variable in flash? > To: "GCC for MSP430 - http://mspgcc.sf.net" > <mspgcc-users@lists.sourceforge.net> > Message-ID: > <90a4f5281002200053q7217fa27q7a959e5a3309c...@mail.gmail.com> > Content-Type: text/plain; charset=ISO-2022-JP > > Hi, Carl. > > You can put asm("") inside the while loop to prevent whole loop optimized > away. > > int main() { > int i = 0; > while (1) { > i++; > asm(""); // __asm__ __volatile__ (""); > } > } > > The pros of this workaround is that the variable i is allocated on register. > > 2010/2/20 Carl <c...@turner.ca>: >> I'm sure that I'm missing some basic here but I'm not sure what. The >> first variable on the stack is in an unexpected location. I would expect >> it to be located somewhere on the stack in RAM (0x30ff-0x1100) but it is >> located in flash memory and it does not get set or incremented. >> >> >> #include <io.h> >> >> int main() >> { >> int i=0; >> while(1) >> i++; >> } >> >> msp430-gcc -g -O0 -mmcu=msp430x2618 -I/opt/msp430/4.4.2/include main.c >> >> (gdb) load a.out >> Loading section .text, size 0x46 lma 0x3100 >> Loading section .vectors, size 0x40 lma 0xffc0 >> Start address 0x3100, load size 134 >> Transfer rate: 1 KB/sec, 33 bytes/write. >> (gdb) c >> Continuing. >> ^C >> Program received signal SIGINT, Interrupt. >> main () at main.c:7 >> 7 i++; >> (gdb) p &i >> $1 = (int *) 0x3102 >> >> >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Mspgcc-users mailing list >> Mspgcc-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/mspgcc-users >> > > > > -- > ?????????????? > takaoka is charging up > > > > ------------------------------ > > Message: 5 > Date: Sat, 20 Feb 2010 14:16:22 -0700 > From: Carl <c...@turner.ca> > Subject: Re: [Mspgcc-users] stack variable in flash? > To: "GCC for MSP430 - http://mspgcc.sf.net" > <mspgcc-users@lists.sourceforge.net> > Message-ID: <1266700583.31623.17.ca...@localhost.localdomain> > Content-Type: text/plain > > If I declare it as a global it is where I expect at the beginning of RAM > (0x1100). But if it is on the stack in the main function, even if I > declare it volatile, use asm(""); // __asm__ __volatile__ (""); or pass > it to a function, the variable address is in flash at 0x3102. It doesn't > make sense. > > Now if I use the program: > > #include <io.h> > > int f1() > { > volatile int i = 5; > i += 2; > return i; > } > > int main() > { > while(1) > { > f1(); > } > } > > The variable i address is on the stack in RAM at 0x30f8 which makes > sense. But if I change the compile option to use -02. Then the function > stack variable, i, goes back to being located in flash at 0x3102. And > it's value is not initialed to 5 nor is 2 added to it. The value of i is > constant = 12544 (0x3100.) > > I noticed at new version of mspgcc4 is out as of Feb 18, 2010. I've > tried to install it on both a Fedora 9 and a Ubuntu machine but get the > same error: > > Failed to execute sh do-gcc.sh "/opt/msp430-gcc-4.4.3" "4.4.3" > "http://ftp.uni-kl.de" "build" "gcc-4.x" "4.3.1" "2.4.1" > at ./buildgcc.pl line 237, <STDIN> line 9. > > > Carl > > > > On Sat, 2010-02-20 at 09:08 +0100, N. Coesel wrote: >> Carl, >> >> Try to declare it outside the function (as a global). >> >> At 19:43 19-2-2010 -0800, you wrote: >>> I tried declaring as volatile and it is at the exact same address. >>> >>> Carl >>> >>> On Sat, 20 Feb 2010 01:35:03 +0000 >>> "Wayne Uroda" <wayne.ur...@grabba.com> wrote: >>>> try declaring i as volatile, or the compiler will probably get rid of it >> since it has no effect or side-effect. >>>> Sent via BlackBerry from Vodafone >>>> >>>> -----Original Message----- >>>> From: Carl <c...@turner.ca> >>>> Date: Fri, 19 Feb 2010 18:29:03 >>>> To: <mspgcc-users@lists.sourceforge.net> >>>> Subject: [Mspgcc-users] stack variable in flash? >>>> >>>> I'm sure that I'm missing some basic here but I'm not sure what. The >>>> first variable on the stack is in an unexpected location. I would expect >>>> it to be located somewhere on the stack in RAM (0x30ff-0x1100) but it is >>>> located in flash memory and it does not get set or incremented. >>>> >>>> >>>> #include <io.h> >>>> >>>> int main() >>>> { >>>> int i=0; >>>> while(1) >>>> i++; >>>> } >>>> >>> > > > > > > ------------------------------ > > Message: 6 > Date: Sat, 20 Feb 2010 23:49:57 +0100 > From: "N. Coesel" <n...@nctdev.nl> > Subject: Re: [Mspgcc-users] stack variable in flash? > To: "GCC for MSP430 - > http://mspgcc.sf.net"<mspgcc-users@lists.sourceforge.net>, "GCC for > MSP430 - http://mspgcc.sf.net"<mspgcc-users@lists.sourceforge.net> > Message-ID: <3.0.5.32.20100220234957.0123b...@192.168.2.20> > Content-Type: text/plain; charset="us-ascii" > > Try this first: > > volatile int i; > > int main() > { > while(1) > { > i++; > } > } > > > IMHO you are chasing a dead horse because the optimizer is removing code > that doesn't do anything. Inside main, the scope of the variable is limited > to main so volatile probably doesn't mean anything. > > > At 14:16 20-2-2010 -0700, Carl wrote: >> If I declare it as a global it is where I expect at the beginning of RAM >> (0x1100). But if it is on the stack in the main function, even if I >> declare it volatile, use asm(""); // __asm__ __volatile__ (""); or pass >> it to a function, the variable address is in flash at 0x3102. It doesn't >> make sense. >> >> Now if I use the program: >> >> #include <io.h> >> >> int f1() >> { >> volatile int i = 5; >> i += 2; >> return i; >> } >> >> int main() >> { >> while(1) >> { >> f1(); >> } >> } >> >> The variable i address is on the stack in RAM at 0x30f8 which makes >> sense. But if I change the compile option to use -02. Then the function >> stack variable, i, goes back to being located in flash at 0x3102. And >> it's value is not initialed to 5 nor is 2 added to it. The value of i is >> constant = 12544 (0x3100.) >> >> I noticed at new version of mspgcc4 is out as of Feb 18, 2010. I've >> tried to install it on both a Fedora 9 and a Ubuntu machine but get the >> same error: >> >> Failed to execute sh do-gcc.sh "/opt/msp430-gcc-4.4.3" "4.4.3" >> "http://ftp.uni-kl.de" "build" "gcc-4.x" "4.3.1" "2.4.1" >> at ./buildgcc.pl line 237, <STDIN> line 9. >> >> >> Carl >> >> >> >> On Sat, 2010-02-20 at 09:08 +0100, N. Coesel wrote: >>> Carl, >>> >>> Try to declare it outside the function (as a global). >>> >>> At 19:43 19-2-2010 -0800, you wrote: >>>> I tried declaring as volatile and it is at the exact same address. >>>> >>>> Carl >>>> >>>> On Sat, 20 Feb 2010 01:35:03 +0000 >>>> "Wayne Uroda" <wayne.ur...@grabba.com> wrote: >>>>> try declaring i as volatile, or the compiler will probably get rid of it >>> since it has no effect or side-effect. >>>>> Sent via BlackBerry from Vodafone >>>>> >>>>> -----Original Message----- >>>>> From: Carl <c...@turner.ca> >>>>> Date: Fri, 19 Feb 2010 18:29:03 >>>>> To: <mspgcc-users@lists.sourceforge.net> >>>>> Subject: [Mspgcc-users] stack variable in flash? >>>>> >>>>> I'm sure that I'm missing some basic here but I'm not sure what. The >>>>> first variable on the stack is in an unexpected location. I would expect >>>>> it to be located somewhere on the stack in RAM (0x30ff-0x1100) but it is >>>>> located in flash memory and it does not get set or incremented. >>>>> >>>>> >>>>> #include <io.h> >>>>> >>>>> int main() >>>>> { >>>>> int i=0; >>>>> while(1) >>>>> i++; >>>>> } >>>>> >>>> >> >> >> >> --------------------------------------------------------------------------- > --- >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Mspgcc-users mailing list >> Mspgcc-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/mspgcc-users >> >> > > > > ------------------------------ > > Message: 7 > Date: Sat, 20 Feb 2010 15:08:15 -0800 > From: <c...@turner.ca> > Subject: Re: [Mspgcc-users] stack variable in flash? > To: "GCC for MSP430 - http://mspgcc.sf.net" > <mspgcc-users@lists.sourceforge.net>, "N. Coesel" <n...@nctdev.nl> > Message-ID: <web-68091...@redback.webnames.ca> > Content-Type: text/plain;charset=utf-8 > > I don't think the optimizer is not removing code or variables when -O0. When > stepping through with gdb if you try to display a variable that is optimized > out, it notifies you by displaying <optimized out>. This is not happening. > > I've tried declaring a global variable it works as expected. > > The problem I'm observing is when a variable is on the stack. > > The code I'm posting is for example only in trying to illustrate a problem in > my code where the stack variables are being used but do not have the expected > values. When stepping through with gdb, the stack variables are is flash. I > have assert statements in my code that catch this even when not using gdb. > > I can post a bigger example if that will help. > > Carl > > > On Sat, 20 Feb 2010 23:49:57 +0100 > "N. Coesel" <n...@nctdev.nl> wrote: >> Try this first: >> >> volatile int i; >> >> int main() >> { >> while(1) >> { >> i++; >> } >> } >> >> >> IMHO you are chasing a dead horse because the optimizer is removing code >> that doesn't do anything. Inside main, the scope of the variable is limited >> to main so volatile probably doesn't mean anything. >> >> >> At 14:16 20-2-2010 -0700, Carl wrote: >>> If I declare it as a global it is where I expect at the beginning of RAM >>> (0x1100). But if it is on the stack in the main function, even if I >>> declare it volatile, use asm(""); // __asm__ __volatile__ (""); or pass >>> it to a function, the variable address is in flash at 0x3102. It doesn't >>> make sense. >>> >>> Now if I use the program: >>> >>> #include <io.h> >>> >>> int f1() >>> { >>> volatile int i = 5; >>> i += 2; >>> return i; >>> } >>> >>> int main() >>> { >>> while(1) >>> { >>> f1(); >>> } >>> } >>> >>> The variable i address is on the stack in RAM at 0x30f8 which makes >>> sense. But if I change the compile option to use -02. Then the function >>> stack variable, i, goes back to being located in flash at 0x3102. And >>> it's value is not initialed to 5 nor is 2 added to it. The value of i is >>> constant = 12544 (0x3100.) >>> >>> I noticed at new version of mspgcc4 is out as of Feb 18, 2010. I've >>> tried to install it on both a Fedora 9 and a Ubuntu machine but get the >>> same error: >>> >>> Failed to execute sh do-gcc.sh "/opt/msp430-gcc-4.4.3" "4.4.3" >>> "http://ftp.uni-kl.de" "build" "gcc-4.x" "4.3.1" "2.4.1" >>> at ./buildgcc.pl line 237, <STDIN> line 9. >>> >>> >>> Carl >>> >>> >>> >>> On Sat, 2010-02-20 at 09:08 +0100, N. Coesel wrote: >>>> Carl, >>>> >>>> Try to declare it outside the function (as a global). >>>> >>>> At 19:43 19-2-2010 -0800, you wrote: >>>>> I tried declaring as volatile and it is at the exact same address. >>>>> >>>>> Carl >>>>> >>>>> On Sat, 20 Feb 2010 01:35:03 +0000 >>>>> "Wayne Uroda" <wayne.ur...@grabba.com> wrote: >>>>>> try declaring i as volatile, or the compiler will probably get rid of it >>>> since it has no effect or side-effect. >>>>>> Sent via BlackBerry from Vodafone >>>>>> >>>>>> -----Original Message----- >>>>>> From: Carl <c...@turner.ca> >>>>>> Date: Fri, 19 Feb 2010 18:29:03 >>>>>> To: <mspgcc-users@lists.sourceforge.net> >>>>>> Subject: [Mspgcc-users] stack variable in flash? >>>>>> >>>>>> I'm sure that I'm missing some basic here but I'm not sure what. The >>>>>> first variable on the stack is in an unexpected location. I would expect >>>>>> it to be located somewhere on the stack in RAM (0x30ff-0x1100) but it is >>>>>> located in flash memory and it does not get set or incremented. >>>>>> >>>>>> >>>>>> #include <io.h> >>>>>> >>>>>> int main() >>>>>> { >>>>>> int i=0; >>>>>> while(1) >>>>>> i++; >>>>>> } >>>>>> >>>>> >>> >>> >>> >>> --------------------------------------------------------------------------- >> --- >>> Download Intel® Parallel Studio Eval >>> Try the new software tools for yourself. Speed compiling, find bugs >>> proactively, and fine-tune applications for parallel performance. >>> See why Intel Parallel Studio got high marks during beta. >>> http://p.sf.net/sfu/intel-sw-dev >>> _______________________________________________ >>> Mspgcc-users mailing list >>> Mspgcc-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/mspgcc-users >>> >>> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Mspgcc-users mailing list >> Mspgcc-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/mspgcc-users > > > > > ------------------------------ > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > ------------------------------ > > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users > > > End of Mspgcc-users Digest, Vol 45, Issue 5 > *******************************************