P-Code
Lectures 27
- For programming a processor we need following
- Instruction Set : Opcode + Operand
- Register Set (programmable)
- Addressing modes
- Pipeline is not a programmable unit.
- Instruction set architectures (ISA)
- We have two types of ISAs:
- CISC: Complex instruction set computer
- RISC: Reduced instruction set computer
- What exactly is reduced in reduced instruction set computer ?
- Opcode : NO
- Number of register set : NO
- Ease of Programming : NO
- Length of instruction : NO
- Time of Execution: NO, for ALU instructions is take s single cycle
- Addressing Modes: YES
- Every ALU instruction is executed only with registers. Instruction set is reduced to have registers as operands for ALU instructions. Therefore it is executed in single cycle. Also all memory instructions are either Load or Store. Therefore it is also called as Load/ Store architecture. As addressing modes are reduced it is called reduced instruction set architecture.
- In RISC, ALU specific instructions have registers as operands. In P-code, they have no arguments. It uses the operand stack to get its operands and store the result.
- It is stack based virtual machine where we do not have explicit operands for ALU specific opcodes.
- P-code was implemented in the 70s to generate intermediate code for Pascal compilers therefore called as Pseudo-code/ Pascal Code.
- Pascal → P-Code → m/c code
Java → Bytecode → m/c code
.Net → MSIL → m/c code
- Javap -c abc.class //gives byte code
javap abc.class //gives java file
- It is called virtualisation because it is layer between OS and Java
- It is used due to its safety in terms of object oriented features and also due to garbage collection, metadatas, array checks, sandbox etc.
- Sandbox gives restricted space to external code which is not trustworthy like applet code.