Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!apple!vsi1!altnet!uunet!mcvax!enea!kth!draken!orjan From: orjan@nada.kth.se (Orjan Ekeberg) Newsgroups: comp.sys.mac.programmer Subject: Re: Question about Bison Message-ID: <594@draken.nada.kth.se> Date: 11 Oct 88 08:49:29 GMT References: <8246@cit-vax.Caltech.Edu> <10329@dartvax.Dartmouth.EDU> Reply-To: orjan@nada.kth.se (Orjan Ekeberg) Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 23 In article <10329@dartvax.Dartmouth.EDU> earleh@eleazar.dartmouth.edu (Earle R. Horton) writes: (Text removed) >alloca PROC EXPORT > move.l (sp)+,a0 ; pop return address > move.l (sp)+,d0 ; pop parameter = size in bytes > add.l #3,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 > move.l sp,d0 ; return pointer > add.l #-4,sp ; new top of stack > jmp (a0) ; return to caller > ENDP > END I tried a similar version of alloca some year ago and seem to remember that it had problems with the C compiler optimizations. Instead of popping garbage from the stack after each call, it sometimes leaves it on the stack and increments the stackpointer later. Problems occur when alloca is called in the meantime. The beginning of the allocated area will then probably be overwritten by another stackframe. I have also tried the portable alloca provided with Gnu Emacs (I think) and it seems to work properly.