synchronize NASM and C Code

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
roswell

synchronize NASM and C Code

Post by roswell »

Hi, I'm designing an OS using NASM and C code.
Sometimes I had trouble with "synchronisation" between C structures and NASM offsets.

In order to avoid this problem, I use a header file which is commun between C and ASM files.

Because C is different than NASM, the layout of the header file is specific in order to work for for both compilers.

Here is the structure of the file :

; /* Comment for both C and NASM

PLACE YOUR ASM CODE HERE

%undef __TAG_TO_EXCLUDE_C_CODE_FROM_NASM__
%ifdef __TAG_TO_EXCLUDE_C_CODE_FROM_NASM__
; End of the comment */

PLACE YOUR C CODE HERE

; /*
%endif
; */


I know this file won't avoid problem because NASM Code is not "linked" to C Code, but because everything is in a single file, you can easily check for synchronisation.

Perhaps there is other way to do the same thing, but I think this code could be helpful for other OS designer. It has been tested with NASM and GCC.

Roswell

PS : It is unuseful to tell me that you can include ASM code in C file with GCC because I want to use NASM.
Tim

Re: synchronize NASM and C Code

Post by Tim »

That's pretty cool! :) I'll remember that...
Post Reply