I've got this code:
char* vidmem = (char*)0xb8000;
int main()
{
vidmem[0] = 'x';
}
but this acts like vidmem is not initalized. if instead i do something like this:
char* vidmem;
int main()
{
vidmem = (char*)0xb8000;
vidmem[0] = 'x';
}
this works perfectly. Why?
I use this lines to compile and link:
gcc -c main.c -o main.o -ffreestanding -fno-exceptions -m64
gcc -m64 -Wl,--build-id=none -static -nostdlib -nodefaultlibs -lgcc main.obj [...] -T linker.ld -o out.bin
using this linker file:
ENTRY(_start)
SECTIONS
{
. = 0x7C00;
.bss :
{
*(.bss);
}
.text :
{
*(.text);
}
}
There is actually some assembly code calling this C file but it should not matter. Am i doing something wrong with gcc? How can i fix it?