Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bloom-beacon!oberon!cit-vax!ucla-cs!zen!ucbcad!ames!lll-tis!ptsfa!ihnp4!homxb!mtuxo!mtune!codas!usfvax2!ateng!chip From: chip@ateng.UUCP (Chip Salzenberg) Newsgroups: comp.lang.c Subject: Re: asm statements & the stack Message-ID: <33@ateng.UUCP> Date: Fri, 9-Oct-87 13:07:33 EDT Article-I.D.: ateng.33 Posted: Fri Oct 9 13:07:33 1987 Date-Received: Mon, 12-Oct-87 06:08:45 EDT References: <110@teletron.UUCP> Reply-To: chip@ateng.UUCP (Chip Salzenberg) Organization: A.T. Engineering, Tampa, FL Lines: 29 In article <110@teletron.UUCP> andrew@teletron.UUCP (Andrew Scott) writes: > > #define disable asm("mov.w %sr,-(%sp)"); asm("mov.w &0x2700,%sr") > /* push current status register on stack, mask out interrupts */ > > #define restore asm("mov.w (%sp)+,%sr") > /* restore status register from stack save location */ > >The compiler I use (stock AT&T /bin/cc) does a wierd thing upon the call to foo. >It allocates one more longword than necessary when creating foo's stack frame. This is a feature! Your C code runs faster as a result. Try the following: #define disable { asm("mov.w %sr,(%sp)"); \ asm("subq.l &4,%sp"); \ asm("mov.w &0x2700,%sr"); } #define enable { asm("addq.l &4,%sp"); \ asm("mov.w (%sp),%sr"); } > Andrew -- Chip Salzenberg "chip@ateng.UUCP" or "{uunet,usfvax2}!ateng!chip" A.T. Engineering My employer's opinions are not mine, but these are. "Gentlemen, your work today has been outstanding. I intend to recommend you all for promotion -- in whatever fleet we end up serving." - JTK