
Introduction
A target machine is a byte-addressable machine with 4 bytes for a word. The target machine has a general-purpose register R0, R1….Rn-1.
The target machine also has three address instructions: op, source, and destination, where op is used as an op-code, and source and destination are used as a data field.
The target machine has the following op-code:
ADD(it adds source to destination)
SUB(it subtracts source from destination)
MOV(it moves source to destination)
A target machine is related to the last phase of the compiler, i.e., the code generator. A code generator is a machine-dependent phase of the compiler because whatever the input is given to the code generator, the code generator converts the input into the final target code.
Also see, Phases of Compiler and,Lexical Analysis in Compiler Design
Instructions
Instructions available in the target machine are as follows:
- Store operation: ST r, x; this instruction stores the value in location x to register r.
- Load operation: LD dst, addr this instruction loads addr location value into location dst. It means dst=addr. This instruction will load the value of location x to location r.
- Conditional jump: The standard form of this operation is Bond,r, L. Where r is registered, L is a label, and cond stands for any of the general tests on the value in register r.
- Unconditional jump: BR L; this operation jumps from branch BR to level L.
- Computation operations: OP dst, src1, src2 OP like operator ADD, SUB.
Addressing Modes
- Variable name: X i.e LD r1,X
- Indexed address: a(r) like LD R!,a(R2) this instruction means R1= contents(a+contents(R2))
- Integer indexed by a register: LD R1, 100(R2)
- Indirect addressing mode: *r and *100(r)
- Immediate constant addressing mode: LD R1, #100
Also See, Top Down Parsing