« Return to Thread: Local Variable vs Global Variable

RE: Local Variable vs Global Variable

by Robert Cragie :: Rate this Message:

Reply to Author | View in Thread

There won't be a .data section as the pointer is now an auto variable and will be either a register or on the stack (most likely a register). So there is no static variable anymore. The string itself will I presume be stored in .rodata - check the output using or32-uclinux-objdump.

Robert Cragie, Design Engineer
_______________________________________________________________
Jennic Ltd, Furnival Street, Sheffield, S1 4QT,  UK
http://www.jennic.com  Tel: +44 (0) 114 281 2655
_______________________________________________________________
 

-----Original Message-----
From: openrisc-bounces@... [mailto:openrisc-bounces@...]On Behalf Of »ªÎÄ
Sent: 24 October 2007 09:17
To: openrisc@...
Subject: [openrisc] Local Variable vs Global Variable

hi ! I have run the simple Hello world program on the or1200 processor following the  Basic custom openrisc system HW/SW tutorial.
The hardware only contains the processor, debug unit,ram and the uart unit.
And  I find a  very strange  phenomenon I do not konw why.
That is  if I modify the hello.c code by making the  'char *str = "Hello world!!!\n" ' inside the main  funciton, the hello world program can not run on the or1200 processor.
By modification,there is not a .data section.  Thank you for your attention, looking forward the answer.
 
the original codes:
char *str = "Hello world!!!\n";
int main (void)
{
  char *s;

  uart_init ();
  for (s = str; *s; s++)
    uart_putc (*s);

  while (1)
    uart_putc (uart_getc () + 1);

  return 0;
}

---->by modification:
int main (void)
{
  char *s;
  char *str = "Hello world!!!\n";
  uart_init ();
  for (s = str; *s; s++)
    uart_putc (*s);

  while (1)
    uart_putc (uart_getc () + 1);

  return 0;

}


_______________________________________________
http://www.opencores.org/mailman/listinfo/openrisc

 « Return to Thread: Local Variable vs Global Variable