On 7/14/20 8:37 AM, dwight via cctalk wrote: > I'm curious as to where the term P-code came from and what defined it. > Dwight
The term "p-code" comes from the 1973 Pascal-P version of UCSD Pascal. There is disagreement as to what the "p" stands for--"portable" or "pseudo". In any case, the technique didn't originate with Pascal. BCPL had an "o-code" which was an intermediate instruction set between the compiler frontend and the target-machine code generator backend. That dates from the 1960s. I worked with a fellow who implemented a COBOL compiler in a CDC 6000-series PPU on a bet with Bill Norris back in the 1960s. I personally worked on a COBOL dialect translator whose implementation language was a p-code that dealt with abstract datatypes, such as tokens, operators, etc. The genius is that you can design a p-code to fit your needs, write to it and then either interpretively execute it or compile it to native machine code. The front end details never change; only the relatively simple back end--and optimization (e.g. loop unrolling, invariant variable elimination, etc.) is much easier with p-code as the object. Said COBOL translator was initially implemented to interpret the p-code, then was later implemented as assembly-language macros to generate native code. The first version was used to debug and test operation, the second (which sped up by 10x) for production use. Later, my team implemented a BASIC compiler which not only generated a p-code, but the compiler itself was implemented in its own p-code. I'd like to know of the first instance of a machine-independent intermediate code use. I suspect that it goes back to the 1950s. --Chuck