Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
guest
Post
by guest » Wed Feb 04, 2004 11:03 am
Ok now I've a problem with global variables, if declare a variable global the value of it is zero!:
Code: Select all
unsigned int n = 15;
int main()
{
if(n == 0)
putstr("n == 0"); // this is out
else
putstr("n == !0");
}
local variables work:
Code: Select all
int main()
{
unsigned int n = 15;
if(n == 0)
putstr("n == 0");
else
putstr("n == !0"); // this is out
}
Therx
Post
by Therx » Wed Feb 04, 2004 11:12 am
Are you loading your DATA section correctly? Or have you written over it by mistake in the program somewhere?
guest
Post
by guest » Wed Feb 04, 2004 11:25 am
do you mean in my linker script??
here is it:
/* Link.ld */
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x100000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data :
{
__CTOR_LIST__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) *(.ctors) LONG(0) __CTOR_END__ = .;
__DTOR_LIST__ = .; LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) *(.dtors) LONG(0) __DTOR_END__ = .;
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}