Hi guys,
I just wanted to ask is their a way to include C header files into assembly language sources, I use the GNU Assembler (AT&T syntax) to assemble my loader and GCC to compile my kernel. The reason I am asking, is that I've had troubles sharing data between my loader and my kernel (BTW I don't use the multi-boot specification). What I do typically is set up a memory location that the loader can write to, which can be read later by the kernel. As my loader grew in functionality, the amount of information sent and received between my kernel and my loader increased, it has become really cumbersome to manage all these offsets. What I'd like is to do is declare these offsets in a single loader.h file and include it into both my loader (Assembly) and my kernel sources (C Sources).
Cheers
Abdullah
Sharing Data Between Loader & Kernel
Sharing Data Between Loader & Kernel
Last edited by Abunada on Mon Aug 17, 2009 11:09 am, edited 1 time in total.
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: Sharing Data Between BIOS & Kernel
I'm not quite sure what this has to do with the BIOS, but it's possible to use the C preprocessor on things other than C, as long as they don't use the #, /*, */, or // symbols for anything, along with some other little things, mostly having to do with whitespace and quotes. I think you can just do something like this, although I haven't tried it:
header.h
assembly.s
Then run something like "cpp -x assembler-with-cpp assembly.s" before assembling.
Hope this helps/works!
header.h
Code: Select all
#define ADDRESS 0x1000
Code: Select all
#include "header.h"
function:
mov edi, ADDRESS
...
ret
Hope this helps/works!
Re: Sharing Data Between BIOS & Kernel
So the command "cpp -x assembler-with-cpp assembly.s" simply runs the C pre-processor on the file. Sounds like its going to work. Thanks a lot, I am off to try it. Oh and sorry what I meant was loader instead of BIOS
Cheers
Cheers