Now , the problem is everything works fine when I load a flat binary prepared by nasm to the memory address 0x2000:0000 (note that PMode is still not enabled , so if i'm wrong please do correct me while I read more about this at osdev forums)
The sequence of operations
Bootloader Up -> Loading module from sector 2 gets printed
Now , instead of the "Loading module from sector 2 gets printed" , i want to print an alphabet 'C' via a Compiled C file. This 'C' is printed with the help of asm directives in the C file (And BIOS interrupt 0x13) . But it doesn seem to work , I tried to different methods to just load the C file correctly , but it doesn work .And I am pretty sure that the issue is with the loading and linking of C code only because I can load and print an nasm prepared flat binary very easily . These are the two scripts I used for linking
link.ld
Code: Select all
OUTPUT_FORMAT("BINARY")
ENTRY(main)
phys = 0x2000;
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 = .;
}
Then , i just added them up into a floppy disk image
Code: Select all
ld -T link.ld -o kernel.bin main.o
dd if=kernel.bin of=floppy.img seek=1 bs=512 count=1 conv=notrunc (seeking 1 because bootloader resides at sector 1 )
qemu -fda floppy.img
if I replace kernel.bin with main.bin (the second stage in assembly , flat binary) ... it works
And the second script
Code: Select all
ld -e _main -Ttext 0x20000 -o kernel.o main.o
ld -i -e _main -Ttext 0x20000 -o kernel.o main.o
objcopy -R .note -R .comment -S -O binary kernel.o kernel.bin
dd if=kernel.bin of=floppy.img seek=1 bs=512 count=1 conv=notrunc
qemu -fda floppy.img
Can anybody please tell me what am I doing wrong ? Please excuse me for my english .