<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 15 Dec 2011 23:00:23 +0000
From   : jgh@... (jgh@...)
Subject: 32016 + 32082

Rick Murray wrote:
> Fair point, but then, how much baggage does BASIC carry that simply
> wouldn't exist in a compiled program?

Even a compiled 6502 program would use it's own stack rather than
the procedure call/return machine stack. 6502 Small-C generates
code along the lines of:

; push intA onto stack
LDA intA+1
STA (stack),Y
DEY
LDA intA+0
STA (stack),Y
DEY

> Surely BASIC makes use of the
> (CPU) stack _itself_, if not necessarily in the course of running the
> loaded program?

It uses continuously throught the course of running the loaded
program, as it does things like JSR NextChar, JSR Evaluator,
JSR OSWORD, etc. It's actually slightly easier to write an
interpreter with a seperate machine stack and data stack as
you don't have to worry about the mixing of subroutine return
addresses and language data on the same stack.

http://mdfs.net/Software/PDP11/BBCBasic/bbcpdp.zip -> 
src/bbcbasic/Stack
shows an implementation of a single machine/language stack.

JGH
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>