Xref: utzoo comp.unix.aux:789 comp.sources.wanted:6983 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!haven!adm!smoke!wouk From: wouk@smoke.BRL.MIL (Dr. Arthur Wouk ) Newsgroups: comp.unix.aux,comp.sources.wanted Subject: Re: alloca(), Anyone have a version that works? Keywords: alloca needed Message-ID: <9998@smoke.BRL.MIL> Date: 6 Apr 89 22:27:59 GMT References: <6049@oxtrap.UUCP> Reply-To: wouk@brl.arpa (Dr. Arthur Wouk (ARO-MATH|jerry) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 42 The following worked for me on an ATT 3b1 when compiling Bison: it came over the net: Originally-From: daveb@gonzo.UUCP (Dave Brower) Subject: Re: Problems compiling gcc on Unix-pc Date: 27 Feb 89 17:29:07 GMT ... I _did_ need to get an alloca from the GNU emacs distribution in order to boot using the at&t compiler. Since few people have room for both gcc and emacs source resident at the same time, here is a crib. The GNU copyleft applies. Put this in alloca.s say "make alloca.o", and fill in ALLOCA=alloca.o in the Makefile. file "alloca.s" global alloca global _alloca _alloca: alloca: mov.l (%sp)+,%a1 # pop return addr from top of stack mov.l (%sp)+,%d0 # pop size in bytes from top of stack add.l &R%1,%d0 # round size up to long word and.l &-4,%d0 # mask out lower two bits of size sub.l %d0,%sp # allocate by moving stack pointer tst.b P%1(%sp) # stack probe to allocate pages mov.l %sp,%a0 # return pointer as pointer mov.l %sp,%d0 # return pointer as int to avoid disaster add.l &-4,%sp # new top of stack jmp (%a1) # not a normal return set S%1,64 # safety factor for C compiler scratch set R%1,3+S%1 # add to size for rounding set P%1,-132 # probe this far below current top of stack Next weekend, g++! -dB -- "I came here for an argument." "Oh. This is getting hit on the head" {sun,mtxinu,amdahl,hoptoad}!rtech!gonzo!daveb daveb@gonzo.uucp