I am thinking about architectures like the 6502 (the stack is limited to 256 bytes -- hardly enough to evaluate any reasonably sized Lisp expression) or the PDP-7 and PDP-8, which stored the return address in the first word of the subroutine, so that subroutines could not call themselves.

It is a well-known property of Lisp that it makes heavy use of recursive routines. For example in typical Lisps that I've seen, eval calls apply, which calls eval again. It is easy to imagine how on a Z80 or x86 or something, a stack frame may contain all the pointers and other data you need. And each invocation of a function can have its own stack frame, as we all know.

My question how people used to implement Lisps on these old and unusual architectures.

  • 3
    The 256 bytes is the hardware stack. The software stack is different. – Chenmunka Nov 8 '16 at 15:32
  • And then, of course, you had machines specifically designed to run Lisp. en.wikipedia.org/wiki/Lisp_machine – JAB Nov 8 '16 at 21:41
  • Here's a modern example of a tiny Lisp interpreter: it fits in 25KB of flash and has a 3KB heap. – Stephen Kitt Nov 18 '16 at 16:36

You are misinterpreting the nature of the Lisp stack. The 256 byte hardware stack of the 6502 processor was not used for the large stacks required by Threaded Interpreted Languages (TILs) like Lisp and Forth. As you say, 256 bytes is grossly inadequate for languages of this type.

The nature of Lisp is to act upon lists of data. A function is merely data and itself sits in a list. This Lisp stack lies within the main memory of the computer.

On the BBC Micro, where my experience of Lisp lies, each call to a function would result in a block of main memory being claimed. This block would hold the return information necessary. It could also hold variables (atoms and lists) declared within the function and could therefore vary in size. The hardware stack was used internally by the language interpreter and the way in which it was used was not made accessible to the Lisp programmer.

These blocks of memory were held in a linked list, which was interspersed with the definition of new functions, and of course, the lists of data upon which Lisp is based and which it is designed to manipulate.

Incidentally, on the BBC Micro you would still run out of memory very quickly. To have any sort of meaningful program you needed to have the optional second processor.

There is some further information in related questions on SO:
and further reading here


For the PDP-1, a scanned and OCR'd (so you can cut & paste) listing of the LISP interpreter is available. This was actually the first LISP implementation, IIRC. The PDP-1 doesn't have any hardware stack; subroutine calls (jsp) store the return address in AC.

So the LISP call stack ("push down list") is implemented in software, using the pointer pdl and the routine pdw to "push down (a) word".

  • 2
    The first implementation of LISP was on an IBM 709, precursor to the IBM 7094. The PDP-1 came later. – John R. Strohm Jun 12 '18 at 21:30
  • Right. This was probably the first interactive LISP interpreter, though. – cjs May 13 '19 at 13:12
  • 1
    Note that the Computer History Museum's Software Preservation Society has made available the source code for the earlier IBM 704 etc. versions of LISP. – cjs Sep 9 '19 at 4:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.