Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!snorkelwacker!ira.uka.de!fauern!tub!net From: net@tub.UUCP (Oliver Laumann) Newsgroups: comp.sys.hp Subject: alloca() on the HP9000/300 Message-ID: <1455@tub.UUCP> Date: 8 Aug 90 17:54:48 GMT Reply-To: net@tub.UUCP (Oliver Laumann) Organization: Technical University of Berlin, Germany Lines: 28 I need an implementation of alloca() for the HP9000/3xx. The alloca() from libPW.a (which makes use of malloca/free) doesn't work for my application; I need an alloca() that actually allocates space on the stack. I came up with the following (I snarfed it from the Sun-3's libc.a and converted the syntax): _alloca: mov.l (%sp),%a0 mov.l 4(%sp),%d0 addq.w &3,%d0 and.l &-4,%d0 sub.l %d0,%a7 mov.l %sp,%d0 addq.w &8,%d0 jmp (%a0) Unfortunately it doesn't work on the HP9000/3xx. Sometime after my application has invoked alloca() the first time, the contents of a register (a local variable) is garbled. Is it possible to write a "real" alloca() for the HP at all, or is there some sort of conflict with the C compiler (i.e. does the way the stack pointer is handled make usage of alloca() impossible)? Thanks, -- Oliver Laumann, Technical University of Berlin, Germany. pyramid!tub!net net@TUB.BITNET net@tub.cs.tu-berlin.de