Target Machine
- The target computer is a type of byte-addressable machine. It has 4 bytes to a word.
- The target machine has n general purpose registers, R0, R1,...., Rn-1. It also has two-address instructions of the form:
Where, op is used as an op-code and source and destination are used as a data field.
- It has the following op-codes:
ADD (add source to destination)
SUB (subtract source from destination)
MOV (move source to destination) - The source and destination of an instruction can be specified by the combination of registers and memory location with address modes.
MODE | FORM | ADDRESS | EXAMPLE | ADDED COST |
---|---|---|---|---|
absolute | M | M | Add R0, R1 | 1 |
register | R | R | Add temp, R1 | 0 |
indexed | c(R) | C+ contents(R) | ADD 100 (R2), R1 | 1 |
indirect register | *R | contents(R) | ADD * 100 | 0 |
indirect indexed | *c(R) | contents(c+ contents(R)) | (R2), R1 | 1 |
literal | #c | c | ADD #3, R1 | 1 |
- Here, cost 1 means that it occupies only one word of memory.
- Each instruction has a cost of 1 plus added costs for the source and destination.
- Instruction cost = 1 + cost is used for source and destination mode.
Example:
1. Move register to memory R0 → M
2. Indirect indexed mode:
3. Literal Mode:
0 Comments