I going to write my os in C with the bootsector in asm. Most of the people that are writing there os in C, are using a bootsector that loads into pmode. I don't want to do this. I want my 16 bit bootsector to load a C file, check the hardware and set up protected mode.
Is there a way to load a C file from a 16-bit bootsector. Will gcc and ld let me compile and link a C file to a 16-bit bootsector?
Bootsector/C file problem
Re:Bootsector/C file problem
I am writing bootsectors for each filesystem. The
bootsector loads a binary file which is the 16 bit
osloader. You can use gcc for 16 bit c, but it is just
easier to use asm. If you do not want a third stage
just link the 16 bit object with you kernel. Here is
an older makefile:
all : init.bin
init.bin : init.o fat12.o cpu.o mem.o vid.o _init.o a20.o
$(LNK) --oformat=binary --entry=Start --Ttext=0x600 --output $(BIN)\init.bin $(OBJ)\init.o $(OBJ)\fat12.o $(OBJ)\cpu.o $(OBJ)\mem.o $(OBJ)\vid.o $(OBJ)\_init.o $(OBJ)\a20.o
init.o : init.S
$(ASM) -o $(OBJ)\init.o init.S
fat12.o : fat12.S
$(ASM) -o $(OBJ)\fat12.o fat12.S
cpu.o : cpu.S
$(ASM) -o $(OBJ)\cpu.o cpu.S
mem.o : mem.S
$(ASM) -o $(OBJ)\mem.o mem.S
vid.o : vid.S
$(ASM) -o $(OBJ)\vid.o vid.S
_init.o : _init.c
$(COM) -o $(OBJ)\_init.o _init.c
a20.o : a20.c
$(COM) -o $(OBJ)\a20.o a20.c
bootsector loads a binary file which is the 16 bit
osloader. You can use gcc for 16 bit c, but it is just
easier to use asm. If you do not want a third stage
just link the 16 bit object with you kernel. Here is
an older makefile:
all : init.bin
init.bin : init.o fat12.o cpu.o mem.o vid.o _init.o a20.o
$(LNK) --oformat=binary --entry=Start --Ttext=0x600 --output $(BIN)\init.bin $(OBJ)\init.o $(OBJ)\fat12.o $(OBJ)\cpu.o $(OBJ)\mem.o $(OBJ)\vid.o $(OBJ)\_init.o $(OBJ)\a20.o
init.o : init.S
$(ASM) -o $(OBJ)\init.o init.S
fat12.o : fat12.S
$(ASM) -o $(OBJ)\fat12.o fat12.S
cpu.o : cpu.S
$(ASM) -o $(OBJ)\cpu.o cpu.S
mem.o : mem.S
$(ASM) -o $(OBJ)\mem.o mem.S
vid.o : vid.S
$(ASM) -o $(OBJ)\vid.o vid.S
_init.o : _init.c
$(COM) -o $(OBJ)\_init.o _init.c
a20.o : a20.c
$(COM) -o $(OBJ)\a20.o a20.c
Re:Bootsector/C file problem
You want to load C source code from a boot sector?Is there a way to load a C file from a 16-bit bootsector. Will gcc and ld let me compile and link a C file to a 16-bit bootsector?
Am I understanding correctly?
Take a look at your gcc/binutils installation. Look how big it is. I wouldn't be surprised if it was 20MB or more. In order to load a C file from a boot sector, you'd have to fit that 20MB program into 512 bytes. Do you think you could do that?