Date : Thu, 28 Jul 1994 10:12:42 +0100 (BST)
From : amh15@... (Alan Hart)
Subject: Re: Assembly and C
> > So in other words there is no portable method of combining C and assembly,
> > even on systems of the same architecture!? I've quite often seen C programs
do
> > a little bit of _asm. The linux kernel for one...
> >
> > I think you must have missed my point. Consider the linux kernel case. It's
> > 99% C, with a few tiny bits of assembly. How can the assembly make use of
> > registers without knowing the internal register allocation used by the C
> > compiler? If we just say 'I will use %o1 as my PC always' then how do
you tell
> > the C compiler not to use %o1 too?
In gcc you can use % symbols to ensure that certain C variables are loaded or
returned into certain assembler registers before you enter/leave (small e,
small l for you 8086 assembler coders) an assembler fragment. Unfortunately
the documentation for this is quite poor. This applies to the DOS port, DJGPP
as well.
I thought there was a (different) mechanism for this in Borland C++, but
maybe I'm just thinking of the _AX etc mechanism, where you can assign and
read the registers in C.
Alan
Alan Hart - amh15@... - University of Cambridge, UK