Header Ads Widget

Target Machine

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:
  1. op source, destination  

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.
MODEFORMADDRESSEXAMPLEADDED COST
absoluteMMAdd R0, R11
registerRRAdd temp, R10
indexedc(R)C+ contents(R)ADD 100 (R2), R11
indirect register*Rcontents(R)ADD * 1000
indirect indexed*c(R)contents(c+ contents(R))(R2), R11
literal#ccADD #3, R11
  • 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

  1. MOV R0, M  
  2. cost = 1+1+1    (since address of memory location M is in word following the instruction)  

2. Indirect indexed mode:

  1. MOV * 4(R0), M  
  2.      cost = 1+1+1   (since one word for memory location M, one word  
  3. for result of *4(R0) and one for instruction)  

3. Literal Mode:

  1. MOV #1, R0  
  2. cost = 1+1+1 = 3   (one word for constant 1 and one for instruction)  

Post a Comment

0 Comments