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 <[email protected]>:
> 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&#174; 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>



-- 
たかおかはちからをためている
takaoka is charging up

Reply via email to