Interrupt routines in 'C'
Ariel Faigon
arielf at taux01.UUCP
Thu Oct 12 18:52:41 AEST 1989
--- Background:
There is a general antagonism between striving to write standard
(portable etc.) C programs, and writing embedded applications in C.
I'm not referring to points that are _clearly_ hardware dependent
and as such expected to be written in assembly, but to general universal
concepts that nevertheless didn't found their way into the language.
The pANS distinguishes between a freestanding (embedded) environment
and a hosted environment. The 'C' language was nicely "hosted" by UNIX
as it was shaped; it seems that the pANS, despite its awareness of the
problem came too late for changing that.
--- Examples:
The best example I can think of are interrupt routines: The code generated
by a compiler for an interrupt routine should be somewhat special, e.g.
it may need to save volatile registers, it may need to return-from-interrupt
instead of a simple 'return-from-subroutine'.
[Initialized data is another example: existing implementations of the standard
library (with roots in some *NIX environment) have initialized static data
which prevents them from being reentrant. The pANS should be blessed on this
issue, as it only allows but not mandates such implementations.]
--- The situation as I see it:
The pANS enables implementation-dependent extensions via the #pragma
directive, while this can solve any one C implementor problem, it leads
to a myriad of distinct solutions which is clearly not what a standard
strives to achieve. On the other hand departing from existing C
by adding keywords (such as 'interrupt') seems to be even a worse
solution (it might eventually lead to a different language :-).
I feel that the least of evils for an embedded C (read cross-C-compiler)
implementor is to look around and try to be as close as possible in his/her
solution to existing implementations (If I'm not mistaken some PC compilers
have an 'interrupt' specifier).
--- My question is:
What in your view is the best way to define an interrupt-routine in 'C' ?
Do you know existing C compilers which solve the problem, what is their
exact syntax to define interrupt routines ?
Any help will be appreciated. Please mail answers to me,
If there are more than 10 answers, I'll summarize.
--
Ariel Faigon, CTP group, NSTA
National Semiconductor (Israel)
6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel Tel. (972)52-522260
arielf%taux01 at nsc.com @{hplabs,pyramid,sun,decwrl} 34 48 E / 32 10 N
More information about the Comp.lang.c
mailing list