Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!rpi!gem.mps.ohio-state.edu!ginosko!xanth!lll-winken!sun-barr!decwrl!nsc!taux01!arielf From: arielf@taux01.UUCP (Ariel Faigon) Newsgroups: comp.lang.c Subject: Interrupt routines in 'C' Keywords: interrupt-routines freestanding-environments pANS Message-ID: <2708@taux01.UUCP> Date: 12 Oct 89 08:52:41 GMT Reply-To: arielf%taux01@nsc.com (Ariel Faigon) Organization: National Semiconductor (IC) Ltd, Israel Lines: 54 --- 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@nsc.com @{hplabs,pyramid,sun,decwrl} 34 48 E / 32 10 N