Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!jade!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga Subject: Re: Dynamic Stack Allocation Message-ID: <8710262105.AA09726@cory.Berkeley.EDU> Date: Mon, 26-Oct-87 16:05:04 EST Article-I.D.: cory.8710262105.AA09726 Posted: Mon Oct 26 16:05:04 1987 Date-Received: Wed, 28-Oct-87 19:37:48 EST Sender: daemon@ucbvax.BERKELEY.EDU Lines: 23 >I have a speedy maze program I wrote in C that I want to send to Fred and post >here, but it needs a large stack. Maximum resolution requires about 150K of >stack space. (Massive recursion.) I don't want everybody who runs it without >reading the docs first to crash their machine. A program which uses that much stack should not assume it will be given it on startup. All you really have to do is allocate enough memory for your stack, then set your SP to the end of it. Be sure to set the SP back to the original stack and free the allocated memory before exiting. Remember that at any time an interrupt can come in and push+pop stuff on the stack. I'd say write a small assembly routine which 'switches' stacks... massiverecursion: (allocate new stack) move.l sp,A0 move.l EndofNewstack,sp move.l A0,-(sp) jsr routine that requires massive recursion move.l (sp)+,sp (deallocate new stack) rts -Matt