« Return to Thread: Local Variable vs Global Variable

Local Variable vs Global Variable

by 华文 :: Rate this Message:

Reply to Author | View in Thread

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