asm

Joseph S. D. Yao jsdy at hadron.UUCP
Sat Nov 30 10:29:07 AEST 1985


First off: the best way to find out for a given C compiler on a
given machine (which is all you want, anyway, since asm's are
inherently non-portable) is to ask the compiler.  Do a cc -S
(cc -S -O if you like) to get an assembler output.

Most C compilers I have run into seem to (note all the hedging) put
register variables into the highest free register first.  E.g., on
the VAX skip PC, SP, FP, AP, and start with R11.  Most C compilers
then allow you down to R6 or R5.  On the PDP-11, one skipped PC, SP,
and FP, and had R4-R2.  The 80X86 is (characteristically) a total
mess: SI and DI are often used, as the closest to real GP registers;
although some will use DX, CX, and BX and skip the optimisations
that using them in-line sometimes bring.  The M680X0 uses the VAX
model, with the interesting twist of address + data registers.  ...

Static and extern data typically has the same name as in the C
program, but with an underscore pre-pended: but not a few have chosen
to change even this simple rule.

Auto's tend to be put on the stack, with the first-declared closest
to the head of the stack and later vars further down.  In the back
of my head there's something nagging at me that there are machines
that do it with the last-declared near the top of the stack.  Either
way, array elements are always in the correct order.
-- 

	Joe Yao		hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}



More information about the Comp.lang.c mailing list