Target Machine
A target machine is a byte-addressable machine. This machine has n general-purpose registers, R0, R1,…..Rn-1. A Simple Target Machine Model has three-address instruction. A full-edged assembly language would have a variety of instructions. The component of instruction is an operator, followed by a target, and then followed by a list of source operands.
Some of the instructions are as follows:
The various addressing modes associated with the target machine are discussed below:
Program and Instruction Costs
The cost refers to compiling and running a program. There are some aspects of the program on which we optimize the program. The program’s cost can be determined by the compilation time’s length and the size, execution time, and power consumption of the target program. Finding the actual cost of the program is a tough task. Therefore, code generation use heuristic techniques to produce a good target program. Each target-machine instruction has an associated cost. The instruction cost is one plus the cost associated with the addressing modes of the operands.
Example
LD R0, R1: This instruction copies the contents of register R1 into register R0. The cost of this instruction is one because no additional memory is required.
LD R0, M: This instruction’s role is to load the contents of memory location M into R0. So the cost will be two due to the address of memory location M is found in the word following the instruction.
LD R1, *100(R2): The role of this instruction is to load the value given by contents (contents (100 + contents (R2))) into register R1. This instruction’s cost will be two due to the constant 100 is stored in the word following the instruction.