So far i have an assembly script that lets you boot from it and write hello world to the screen. now i want to be able to write some c code and be able to have my assembly script run it somehow. Im using mingw gcc for my compiler. This is my bootloader in assembly:
org 7C00h
jmp short Start
Msg: db "Hello, world" EndMsg: Start: mov bx, 000Fh
mov cx, 1
xor dx, dx
mov ds, dx
cld Print: mov si, Msg
Char: mov ah, 2
int 10h
lodsb
mov ah, 9
int 10h
inc dl
cmp dl, 80
jne Skip
xor dl, dl
inc dh
cmp dh, 25
jne Skip
xor dh, dh
Skip: cmp si, EndMsg
jne Char
jmp Print times 0200h - 2 - ($ - $$) db 0
dw 0AA55h
My question is how to compile the c code so that the assembly script will execute it? also how would i edit my current boot loader so that would be possible?
First, you should select a compiler to use and study its specifics. C programs can be compiled for “hosted” environment which supposes standard initialization, main() as entry point and standard library, and “freestanding” environment where such guarantees aren’t provided. To call C code you shall do appropriate environment setup (stack, data segments, etc.) in the bootloader. Details for this are compiler-specific. Converting of object code to form suitable for your bootloader can also be problem.
For 16-bit code, there are at least Turbo C and Watcom C available for free use. Watcom is more progressive and modern and is open source now.
Note that standard library is unavailable in such setup, so C code shall be specially written for your environment; this includes such underwater stones as e.g. multiplication of 32-bit longs was usually implemented in library, despite you don’t write library call.
[In general, I’m confused with your request to use precisely C; as soon as bootloader unlikely needs execution speed, it’s more proper to use something more applicable for such context, as Forth. There are ready to use implementations (see FreeBSD bootloader).]