Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!cybvax0!frog!john From: john@frog.UUCP (John Woods, Software) Newsgroups: comp.lang.c Subject: Re: asm statements & the stack Message-ID: <1666@frog.UUCP> Date: Thu, 15-Oct-87 15:59:00 EDT Article-I.D.: frog.1666 Posted: Thu Oct 15 15:59:00 1987 Date-Received: Sat, 17-Oct-87 09:26:43 EDT References: <110@teletron.UUCP> Organization: Superfrog Heaven [ CRDS, Framingham MA ] Lines: 42 In article <110@teletron.UUCP>, andrew@teletron.UUCP (Andrew Scott) writes: > > Many C compilers have one variation or another on the asm() "function"... > What can I do in an asm() statement? "Nothing." > The question arises because I was > bitten by the compiler's code generation method. That's where the answer comes from. > I was writing a function which must be non-interruptable. ... > Should I be angry with the compiler writer...? No. The only solution you can believe in is to use function calls to assembly modules. This way, you can (A) know that it really works for real, not by accident, (B) change the compiler at will (next release of the same one, or a new compiler altogether -- which would basically chuck your old asm()s out the window, most likely, and SOME compilers do not permit asm statements at all (some don't even have an assembly language intermediate stage)), and (C) change to a new processor type with less effort (the assembly code is localized in one module). If your time-critical routine cannot deal with wasting 72 clock cycles on subroutine linkage (5.76 microseconds at 12.5Mc, plus wait states), then you probably ought to write the whole routine in assembly, because the C compiler is probably wasting more than that on other little bobbles. "Pluck the millisecond-wasting bad algorithms from thine own mind before complaining about the micro-second wasting nature of high-level languages." Or something like that. -- John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101 ...!decvax!frog!john, ...!mit-eddie!jfw, jfw@eddie.mit.edu "Cutting the space budget really restores my faith in humanity. It eliminates dreams, goals, and ideals and lets us get straight to the business of hate, debauchery, and self-annihilation." -- Johnny Hart