I am working on a program (for real real mode) that is loaded by a bootloader to an address in memory and jumps to it and starts executing the program. The problem is that I have the project separated into two files: a.asm (16bit asm, NASM syntax) and b.c (which i compile with gcc for dos (djgpp)). Also, b.c uses some functions from the allegro library (I have it as a static library, .a).
My question is, how do I compile and link these 3 files together? My first thought was to:
- Compile and assemble b.c with gcc (with the -c flag), as a result I get a b.o file
- Assemble a.asm with NASM (-fbin or.. ?) and get a.o
- Link b.o, a.o and allegro.a to get a pure binary (no .exe headers, no debug information etc.)
I tried the above approach, but at the step 3, the linker throws an error saying that the format of a.o (the object file generated by NASM), is unrecognized, and that may be because either I am not invoking the right flags and options when assembling the file, or..
I would like some guidance on how to approach this problem.
Thanks.