Documentation, Registers, FLAME

Kurt Guntheroth kurt at fluke.UUCP
Sat Sep 10 01:12:35 AEST 1983


I am a c programmer.  I am not naive.  I know nothing about register usage
on any of the c compilers I have used.  I have done anything I could to
avoid looking at assembly code and the people I work with do likewise.  I
look at assembly code when:

  * I want to optimize code that is very time critical.  I try to understand
    the way the compiler generates code so I can write c statements that are
    translated to the most efficient object code.  (I hate doing this and
    think the compiler should not care whether I say (i+1) vs. (1+i) but
    there it is.)

  * I need to re-code a c routine in assembly for the ultimate in speed.  I
    never (so far) write in assembly from scratch, but instead optimize lthe
    code the compiler produces which is usually pretty good.

  * I think there is a bug in the compiler.

I agree that register usage should not be discussed in polite company.  If
the compiler is mysterious in register usage then it should have a form of
external procedure call where the register usage is not mysterious and this
form of call should be used when linking in procedures written in other
languages.

Note that usually register usage is the least of your worries when interfacing
procedures written in different languages.  (Compared to whether the two
languages have compatible calling sequences, data structures, etc.)  I guess
a decision has to be made as to whether a language will allow functions
written in other languages to be linked in, and then provide facilities to
make it non-mysterious.  If these facilities are not provided, and somebody
still wants to poke his fingers into the implementation, then s/he has no
reason to complain if the language does mysterious things with registers and
does not tell him about them.

To summarize; the ability to link to procedures in other languages is a
feature of a specific implementation.  If the calling conventions and
register usage are not documented, it is probably because the implementation
does not care to provide the ability to link to foreign procedures.  If a
user wants to extend the implementation to linking to foreign procedures,
such a user must expect to work hard to overcome lack of documentation, not
gripe about how hard the job is.

Kurt Guntheroth
Software Engineer
John Fluke Mfg. Co., Inc.



More information about the Comp.lang.c mailing list