C and Me

In 1970 I was of the school that kernels and such should be written in assembler. We had written a kernel for the IBM 370 in assembler and the time was coming to port it to other machines. I looked at the language definition of C and our kernel data models did not fit those of C. Someone proposed to me that real C compilers did what you wanted and that you could look at C as a portable assembler unconstrained by language definitions. I played a bit with that idea and with the help of others found it possible to express our assembler code in C with little damage. Only occasionally did we subsequently resort to assembler for performance or for the first or last few instructions of an interrupt routine.

I posit that today there are many C programs that do just what their designers planned, and would be judged invalid according to the defining document. An anecdote is that some recent C compiler silently omitted the zeroing of a buffer just before freeing it, judging it superfluous. The buffer held crypto keys. See

I think there are now two species of C programs and programmers and we need a standard for each. Much compiler technology can be shared. Perhaps a command line flag. I suspect the assembler mode must specify that integers are two’s complement and 32 or 64 bits long.