- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm new to nios2 developpement and i'm having problems running the simple hello_world exemple : When I lauch this code :int main()
{
unsigned char i,j,k;
printf("Hello from Nios II!\n");
while(1){
i++;
j++;
k++;
if(k==100){
printf("a");
}
}
return 0;
}
in the debugger, i can see that the 'i' variable is incrementing correctly, but the 'j' variable always have the value 203 and the 'k'variable always have the value 0. Although i cant see the 'k' value changing, the program does go in the if statement. Could anyone explain to me why i cant monitor correctly the variables values? Thanks ps: running this program, i also have an other problem regarding the console ouput as described in this post : alteraforum.com/forum/showthread.php?t=27499. I supposed it could be related
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quite possibly the values are in registers and/or optimised away.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
but why can I read 'i' correctly but not 'j' and 'k' ?
The thing is, i noticed this problem is some other project where i really needed to read back some avalon-slave-module registers values. I was getting really strange values so i then tried to run the simple hello_world on my board to see if i still had problems. could the problem come from a bad sopc builder configuration ?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Look at the generated code...
gdb can't really guarantee to give you the values of variables that are in registers. Although if you aren't compiling with -O2 (you really should use -O2 or -O3) then it is likely that all the expected code (including all the load/stores from stack for the local variables) is actually generated. Marking global data 'volatile' will force all references in the C source to generate load/store instructions.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page