Iteration for Factorials

Hendrik van Rooyen mail at microcorp.co.za
Tue Oct 23 10:36:46 EDT 2007


"Dennis Lee Bieber" <wlfraed at ix.netcom.com> wrote:

> >
> Heh... the one saving grace of taking a CS major in a period where
> the primary languages taught were FORTRAN (IV), COBOL (74), and
> something close to K&K BASIC. Heck, even the assembler class followed
> the FORTRAN parameter handling scheme (argument addresses copied to
> static locals and used via one level of indirection) -- It would take me
> some time, today, to figure out how to even create a "stack" (even the
> return address was passed via a reserved register and saved locally):
> 
> call,2 sub-address
> data arg1-address
> data arg2-address
> do-something
> .
> .
> .
> sub-address: store,2 my-return
> load,9 *my-return,1 ;indexed access
> store,9 param1
> load,9 *my-return,2
> store,9 param2
> do-stuff
> load,2 my-return
> addimmediate,2 2 ;number of args to
> adjust return
> return,2
> 
> (format:
> label command,register argument
> *argument ;indirection
> argument,x ;indexed )
> -- 

Yuk.  Reminds me of one of the Hitachi processors that
has a single depth hardware "link register" that tells a 
subroutine where it was called from.

I was thinking of a stack that grows when you call or push,
and shrinks when you return or pop.

When there are only 128 or so bytes, and an address is two bytes, 
recursive calling soon runs into trouble.  Especially so if you also 
use the stack to pass params... 

- Hendrik





More information about the Python-list mailing list