We start with a model.
Example: STATEMENT IMLPEMENTATION:
Execute the significant level proclamation: a = a + b + a * c
on a 3-address machine; expect that factors a, b, c are in registers r1, r2, and r3 individually.
Answer:
MUL r4, r1, r3 # use r4 as a transitory
Include r1, r1, r2 # a + b in r1
Include r1, r1, r4 # conclusive outcome in r1
Note that if the estimations of b or c are not, at this point vital, one of the registers r2 or r3 could be utilized as a transitory.
In this model two out of three guidelines have just two unmistakable locations; one of the operands is both a source operand and the goal. This circumstance happens rather habitually with the end goal that you may think it merits characterizing a 2-address machine, as one in which directions have just two locations.
The General Configuration Of Guidelines Is:
Activity Dest, Operation Where
• Operation is the name of the activity to be performed
• Dest assigns the name of one source operand and the name ofthe goal
Therefore The Importance Of A Guidance Like:
Include r1, r2
is to include the qualities put away in the registers r1 and r2, and to store the outcome in r1.
There is a bit of leeway in having two-address guidelines as contrasted and three-address directions, specifically that guidance are shorter, which is significant while saving memory is at huge cost; in addition shorter guidelines may be brought quicker (for the situation directions are more extensive than the datapath and various gets to memory are required). There is a disadvantage anyway with two-address guidelines: one of the source operands is obliterated; subsequently additional moves are once in a while important to protect the operands that will be required later.
Example: STATEMENT IMLPEMENTATION
Tell the best way to actualize the elevated level proclamation
On a 3-address machine and afterward on a 2-address machine. The two machines are 8 piece register-register machines with 32 broadly useful registers and a 16 piece addresses. The estimations of factors a, b, and c are put away in r1, r2 and r3 separately. Regardless compute the quantity of clock cycles fundamental if each memory get to takes two clock cycles and the execution period of a guidance takes one clock cycle.
Answer:
For the 3-address machine:
Include r1, r1, r2 # 3 * 2 + 1
Include r1, r1, r4 # 3 * 2 + 1
This succession requires 21 clock cycles to finish; every guidance has a bring stage that takes three (3 bytes/guidance) times two clock cycles (2 clock cycles for each memory access), in addition to an execution stage which is one clock cycle long.For the 2-address machine:
Include r1, r2 # 2 * 2 + 1
Include r1, r4 # 2 * 2 + 1
The succession requires 20 clock cycles to finish; it is somewhat quicker than the execution of a similar explanation on the 3-address machine. The two location machine requires 10 bits (5 + 5) to encode the two operands and the model accept a guidance is 16 piece wide.
The above model has presented another two operands guidance:
MOV Dest, Operation
Which (moves) the worth put away at address operation to address dest.
Regardless of whether the MOV guidance is run of the mill two operands guidance there is no motivation to trust it just has a place with 2-address machines: a 3-address machine is one in which directions determine up to 3 operands, not a machine in which all guidelines have absolutely 3 operands.
In this segment we examined about a register-register, 2-address machine.
No comments:
Post a Comment