OK... i think i fixed it.
i changed the name of the main function to "kmain".
im using this linking script:
Code: Select all
ENTRY(main)
phys = 0x00001000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
and the bat file:
Code: Select all
nasm bootsect.asm -f bin -o build\bootsect.bin
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o build\main.o main-basic.c
gcc -c video-basic.c -o build\video.o
gcc -c string-basic.c -o build\string.o
ld -T link.ld -o build\kernel.o build\main.o build\video.o build\string.o
objcopy -R .note -R .comment -S -O binary build\kernel.o build\kernel.bin
makeboot build\a.img build\bootsect.bin build\kernel.bin
pause
but!!!
now im having a new problem... and I think its related to the way i compile things.
im trying to print "hello world" on the screen, but then i am trying, im having some very weird problems...
then i trying to print something with a length of 1 or 3 characters its look like the string is empty. when the length is 4-5 its normal, and when its more then 5 its crashes...
thats the way im trying to use the function.
Code: Select all
const char hello[] = "hello";
kprint(&hello);
this is the function:
Code: Select all
void kprint(char *_message)
{
unsigned int i=0;
unsigned char *vidmem = (unsigned char *)0xB8000;
while (_message[i] != 0) {
*vidmem = _message[i];
vidmem += 2;
i++;
}
out(0x3D4, 14);
out(0x3D5, (unsigned char)(0));
out(0x3D4, 15);
out(0x3D5, (unsigned char)(i));
}