PASCAL.BAS and INTERP.BAS are derived from a three-part article by Kin-Man Chung and Herbert Yuen in the Sep/Oct/Nov 1978 issues of Byte Magazine. Those issues provide the syntax diagrams of the subset of Pascal which it can parse, along with implementation details. In short, structs, pointers, file types, and user defined types are not supported, only INTEGER and one-dimensional ARRAY of INTEGER types are supported. Constant strings (eg, 'THIS IS A STRING') are supported, but only by the WRITE () procedure. PASCAL.BAS -- Tiny Pascal compiler The program asks for the base name Tiny Pascal source file (eg, if the source file is named FOO.P, the name FOO is entered into the program), and produces P-code in memory. Converted to CCII by T.G. Price, 8/80 INTERP.BAS -- INTERP.LDA -- This is the P-code interpreter which executes the P-code version of the Tiny Pascal program. It includes some simple debugging aids. I'm not sure what INTERP.LDA is for, since INTERP.BAS doesn't load it. TSCONV.BAS -- Text to src and V/V Conversion by K.G. Winder, CUVIC WPNEW.PRG -- Word processor v6.0, by G. Epps, for v8.79 BASIC WPOLD.PRG -- Word processor v6.0, by G. Epps, for v6.78 BASIC ============================================================================ I've spent a bit of time figuring out how this works. PASCAL.BAS compiles the PASCAL program off of disk into p-code which is stored in RAM, then exits. Next, INTERP.BAS is loaded and run, and one must specify where the p-code is located so it can run the p-code. For example, using the editor (WPOLD.PRG), create a file with a simple program. FCS>RUN WPOLD (the program starts) CONST CR=13;LF=10; BEGIN WRITE ('HELLO WORLD!',CR,LF); END. (it asks name of file to save it to) TEST.P (file is saved to disk) (quits editor) Note that it is important to indent the END. statement as shown. When I first tried it, I had END at the left edge of the screen, but when I tried to compile I'd get a "IDENT UNKNOWN" fatal error. This seems like an error in the compiler. OK, now get back to BASIC, using and specify that you want just 28000 bytes of RAM used for BASIC. This will give us all the RAM above 0xF000 free to hold P-code. Feel free to reserve a different amount of RAM; this is simply what I used and I know it works. LOAD "PASCAL":RUN When it runs it asks where to start the p-code; enter 61440 (0xF000). It asks if you want the generated p-code displayed during compilation; enter either Y or N, your choice. Then it runs for a minute, ending with COMPILATION COMPLETE P-CODE STARTS AT 61440 : ENDS AT 61524 Now load up the p-code interpreter: LOAD "INTERP":RUN It begins with STARTING ADDRESS? 61440 (enter the same number you gave the compiler) 0 JMP > It has disssembled the first p-code instruction and ">" is the prompt asking what to do. Type to tell it to RUN. A=3HELLO WORLD! 21 INSTRUCTIONS EXECUTED and it is done. I'm not sure why "A=3" is printed. Other commands: G: go set program counter to zero; initialize other counters; start execution S: single-step execute one p-code; display the mnemonics of the next p-code pointed by the updated program counter R: run/restart start execution from current program counter until the program ends or a breakpoint is reached. This command is used to continue execution at a breakpoint. B: set breakpoint a p-code address is entered as a breakpoint after the interpreter prompts with a ?. Up to five breakpoints may be set. C: clear all braekpoitns previously set are cleared Y: display breakpoints display the breakpoints already set X: examine status display the values of the current program counter, base address, stack pointer, and the top two elements of the stack K: stack content a value is entered as the stack pointer after the interpreter prompts with a ?. it will then display the values of six stack elements starting from this stack pointer. T: trace display the address and mnemonics of the 16 p-codes last executed. This command is usualy applied at a breakpoint. It is used for tracing the logic flow of the program. E: examing program a p-code address is entered as a display pointer (DP) after the interpreter prompts with a ?. It will then display the mnemonics of the p-code at this address. This command and the U and N commands are used for examining the p-codes anywhere in the program without altering the current program counter. U: up (!! the CCII version seems to use 'V' instead of 'U') decrement the display pointer by one and display the mnemonics of the p-code pointed by it. N: next increment the display pointer by one and display the mnemonics of the p-code pointed by it. Q: quit terminate the interpreter program and return to the operating system. The original article had the same P-code interpreter as in INTERP.BAS, but it also had an option to translate the P-code to native 8080 machine instructions. This one doesn't.