One of my projects is an effort to analyze the P-code structure and interpreter with the ultimate aim of eventually producing an interpreter running on the 6502. Because their compiler is supplied in P-code running on the same interpreter, it is hoped that when the interpreter is done, the compiler comes along for the the ride.
While I do not understand how the stack or their environment works yet, I have identified a number of the interpreted instructions. It is hoped that the instructions can provide insight into the particulars of the stack and environment.
A P-code binary file is structured as follows: from compiling this program:
Code: Select all
PROGRAM EMPTY;
BEGIN
END.
Opcode $06 appears to be setting up the initial stack frame.
It is not known what the six bytes are. Some of them can be presumed to be for the standard input and output file streams.
Opcode $00 appears to be shutting down the program, but disassembly of the code for that instruction shows it potentially does much more than that.