Portable "asm" <-- portable? since when?

Henry Spencer henry at utzoo.uucp
Sat Mar 12 08:10:17 AEST 1988


> If the #asm has to come back, let's just revert to the old K&R style:
> 
> 	#asm
> 	; assembly goes here
> 	#endasm

What "K&R" style?!?  There is no "asm" or "#asm" in K&R.  (It is mentioned
once, in the Reference Manual, as a keyword reserved by some compilers.)

> I *would* like to see the "interrupt" keyword added to ANSI C (or D).
> For a language to claim to be a system programming language and not
> provide the capability to write interrupt routines is a major oversight
> (although K&R seemed to do fine without it :-)...

This is a curious statement, given that all Unix's interrupt routines are
written in C.  There is a little bit of assembly-language glue involved
on most machines, but all that does is smooth over differences in calling
conventions.  If you are willing to live with the idea that you can't
just plop a function's address into an interrupt vector, but some small
amount of mediation is required, no language change is necessary.  It's
not as if what you were doing was portable and could usefully be made
standard across different implementations.  (If you think it is, consider
for example that my machine's interrupt vectors are structures, not just
single pointers, so just filling in a function pointer is not enough.)

> Also, I would like to see named access to specific CPU registers included
> in ANSI C, e.g. AX, BX, R0, R1, etc...

Subject to certain rules about naming conventions, ANSI implementations
are free to provide whatever machine-dependent magic cookies they want.
So are non-ANSI implementations, for that matter.  Complain to your vendor
if he doesn't do what you want.  Actually *specifying* what should be
done is so hopelessly machine-dependent and implementation-dependent that
no standards committee in its right mind would put it into a standard.
-- 
Those who do not understand Unix are |  Henry Spencer @ U of Toronto Zoology
condemned to reinvent it, poorly.    | {allegra,ihnp4,decvax,utai}!utzoo!henry



More information about the Comp.lang.c mailing list