Message on thread Stack Usage?

Re: Stack Usage? (2018-07-07 14:31, SHIRAISHI Kazuo, #81583)

[Reply To Message #81579]
> In the various version of Decimal BASIC (Decimal, Acc and Acc2) how many bytes does each call to an iterative function take? Is it dependent on the number of parameters?
>
> I have an Ackermann function and I'm trying to calculate the number of bytes on the stack at each iteration.
>
> FUNCTION ackermann(m,n)
> LET stksiz=stksiz+32 ! The 32 is the number to be replaced so I need to know how much each call adds to stack size
> LET ncalls = ncalls + 1
> LET curstack = stksiz
> IF curstack > stacksize THEN
> LET stacksize = curstack
> END IF
> IF m = 0 THEN
> LET ackermann=n+1
> EXIT FUNCTION
> END IF
> IF n = 0 THEN
> LET ackermann=ackermann(m-1,1)
> EXIT FUNCTION
> END IF
> LET ackermann=ackermann(m-1,ackermann(m,n-1))
> END FUNCTION
>
> A number takes 8 bytes, correct? That would mean that this would take 16 bytes plus some for the return address. Is the total number easily calculable?

That is right for BASICAcc and BASICAcc2 binary mode.
Single numeric variable Parameters takes 8 bytes for each, and the return address takes 8 bytes on the 64 bit mode.



Reply to #81579

Reply to #81583×

You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Thread

Stack Usage? (2018-07-06 21:53, toml_12953, #81579)
Re: Stack Usage? (2018-07-07 14:31, SHIRAISHI Kazuo, #81583)
Re: Stack Usage? (2018-07-07 17:25, SHIRAISHI Kazuo, #81585)
Re: Stack Usage? (2018-07-07 18:47, toml12953, #81588)
Re: Stack Usage? (2018-07-08 09:31, SHIRAISHI Kazuo, #81592)
Re: Stack Usage? (2018-07-14 10:30, Shiraishi Kazuo, #81601)
Re: Stack Usage? (2018-07-07 17:54, SHIRAISHI Kazuo, #81587)