Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assembly and C

Status
Not open for further replies.

oconnellb

Programmer
Jan 21, 2001
3
US
I am working on creating my own operating system and
I've written it all in Assembly so far and for debugging
reasons I want to rewrite some of it in C. The problem
is that I'm not very experienced with C and I need to
be able to link my assembly code with my C code in
a way that allows me to share variables. I'm not
familiar with GAS format so simply using this in the C
code is out of the question.

Does anyone have any suggestions? Tutorials?

Thanks
 
When you are doing a project in C,just use:

...
_asm
{
/*here you insert your code in assembler*/
}
...

you will be able to use all the variable you declared in that block,just make sure the size of operands coincide.
Best Regards,

aphrodita@mail.krovatka.ru {uiuc rules}
 
HI,
Really nice to know that u have done it all in assembly.
I too started writing that way, (coz i was scared at GCC,
inline assemly..)
But now i have moved all my code to c and "assmebly".

I would rather advice u to port ur code to "C"..(provided
u r in the begining stage...) That would help u a lot.

Write "C" code, compile and link it to a binary 32-bit
image, ( U have linker scripts , which help u
to relocate code to any address..For exp, if u want to
have ur kernel addresses start from C0000000h, u can tell
"ld" via linker scripts..its so flexible..Try "info ld" in
Linux)

Write bootsector in assembly, load the kernel and pass
control to it..Since "C" code is pure 32-bit, u need to be
in PM b4 jumping into "C" code.
All the best
Regards,
Sarnath
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top