Reentrant Programming: Small versus Big Software Stacks

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
Druzyek
Posts: 367
Joined: 12 May 2014
Contact:

Re: Reentrant Programming: Small versus Big Software Stacks

Post by Druzyek »

Quote:
whartung wrote:
Druzyek wrote:
Exactly. This is why I think a program to figure out what goes where would be a great help.
They call programs that do this "compilers".
What I'm thinking about would better be called an optimizer. To be a compiler it would have to produce machine code, not just reworked assembly.
Quote:
This is exactly what prompted me to come up with PLASMA: Proto Language AsSembler for Apple.
Quote:
Cool! I saw one of your demonstration videos about PLASMA. Are you still working with byte code? How do you split up memory usage in functions between zero page and the data stack?
whartung
Posts: 1004
Joined: 13 Dec 2003

Re: Reentrant Programming: Small versus Big Software Stacks

Post by whartung »

Druzyek wrote:
To be a compiler it would have to produce machine code, not just reworked assembly.
Sorry, can't say I quite see the difference.

Many compilers create assembly source code. Even compiler writers realize its far easier for an assembler to create machine code than to incorporate all that in to the code generation of the compiler itself.

Naturally there are always exceptions.
resman
Posts: 154
Joined: 12 Dec 2015
Location: Lake Tahoe
Contact:

Re: Reentrant Programming: Small versus Big Software Stacks

Post by resman »

Druzyek wrote:
Quote:
whartung wrote:
Druzyek wrote:
Exactly. This is why I think a program to figure out what goes where would be a great help.
They call programs that do this "compilers".
What I'm thinking about would better be called an optimizer. To be a compiler it would have to produce machine code, not just reworked assembly.
Quote:
This is exactly what prompted me to come up with PLASMA: Proto Language AsSembler for Apple.
Quote:
Cool! I saw one of your demonstration videos about PLASMA. Are you still working with byte code? How do you split up memory usage in functions between zero page and the data stack?
This is where I diverged from the original concept of three output options: byte code, threaded code, and pure native code. The code is still on the backwaters of SourceForge: http://vm02.sf.net but I've focussed on the byte code implementation for all subsequent versions. It's pretty easy to conceptualize the byte codes as macros to be expanded in-line.

The zero page usage breaks down as a split evaluation stack indexed by X, a NEXTOP/FETCHOP that isn't needed for non-bytecode implementations, a local frame stack pointer for all the local variables, and some temps. All values are copied to the evaluations stack for processing (but caching TOS in A,Y really helps here for native code).

Dave...
Post Reply