Question: Compare zero - , one - , two - , and three - address machines by writing programs to compute G = ( A x

Compare zero-, one-, two-, and three-address machines by writing programs to compute
G =(A x B C x D)/(A + B x C - D)
for each of the four machines. Assume that A, B, C, and D above refer to memory locations. You may also use temporary memory locations named T1, T2, T3, etc. if necessary.
*********** Also G is a memory location **************
The instructions available for use are as follows:
0-Address
1-Address
2-Address
3-Address
PUSH X
LOAD X
LOAD R, X
MOVE R, P
POP X
STORE X
STORE R, X
MOVE X, R
ADD
ADD X
ADD R, P
ADD R, P, Q
SUB
SUB X
SUB R, P
SUB R, P, Q
MUL
MUL X
MUL R, P
MUL R, P, Q
DIV
DIV X
DIV R, P
DIV R, P, Q
In the above, X refers to a memory location (e.g. A or T2), R refers to a register (e.g. R4 you may assume up to 15 registers), and P and Q refer to either a register or a memory location.
Explanations of Instructions:
0-address: PUSH X pushes the operand at memory address X onto the stack; POP X pops the stack and stores the popped value in memory address X; the arithmetic operations pop the top two elements from the stack, perform the operation on them, and push the result onto the stack, e.g., SUB: result (second popped element first popped element).
1-address: There is only one CPU register called Accumulator (ACC). LOAD X: ACC M[X]; STORE X: M[X] ACC; SUB X: ACC ACC M[X].
2-address: LOAD R, X: R M[X]; STORE R, X: M[X] R; SUB R, P: R R P where P may be a register or a memory operand.
3-address: MOVE R, P or MOVE X, R: first operand (destination) second operand (source); SUB R, P, Q: R P Q.
Questions to be answered:
First write a program for each machine to compute the given expression. Hint: For the 0-address machine, first convert the expression into reverse Polish (or postfix) notation.
Calculate the total size of each program in bits under the following assumptions: The opcode is 4 bits long, each register number in an instruction is 4 bits long, and each memory address in an instruction is 16 bits long.
What conclusions can you draw from the above exercise? Use the following criteria as the basis of your comments: program size in instructions, program size in bits, average length of an instruction, number of registers, and usability of registers. Based on these criteria, which of the above machine types should be preferred for programs similar to the above?Compare zero-, one-, two-, and three-address machines by writing programs to compute
G =(A x B C x D)/(A + B x C - D)
for each of the four machines. Assume that A, B, C, and D above refer to memory locations. You may also use temporary memory locations named T1, T2, T3, etc. if necessary.
*********** Also G is a memory location **************
The instructions available for use are as follows:
0-Address
1-Address
2-Address
3-Address
PUSH X
LOAD X
LOAD R, X
MOVE R, P
POP X
STORE X
STORE R, X
MOVE X, R
ADD
ADD X
ADD R, P
ADD R, P, Q
SUB
SUB X
SUB R, P
SUB R, P, Q
MUL
MUL X
MUL R, P
MUL R, P, Q
DIV
DIV X
DIV R, P
DIV R, P, Q
In the above, X refers to a memory location (e.g. A or T2), R refers to a register (e.g. R4 you may assume up to 15 registers), and P and Q refer to either a register or a memory location.
Explanations of Instructions:
0-address: PUSH X pushes the operand at memory address X onto the stack; POP X pops the stack and stores the popped value in memory address X; the arithmetic operations pop the top two elements from the stack, perform the operation on them, and push the result onto the stack, e.g., SUB: result (second popped element first popped element).
1-address: There is only one CPU register called Accumulator (ACC). LOAD X: ACC M[X]; STORE X: M[X] ACC; SUB X: ACC ACC M[X].
2-address: LOAD R, X: R M[X]; STORE R, X: M[X] R; SUB R, P: R R P where P may be a register or a memory operand.
3-address: MOVE R, P or MOVE X, R: first operand (destination) second operand (source); SUB R, P, Q: R P Q.
Questions to be answered:Compare zero-, one-, two-, and three-address machines by writing programs to compute
G=AB-CDA+BC-D
for each of the four machines. Assume
First write a program for each machine to compute the given expression. Hint: For the 0-address machine, first convert the expression into reverse Polish (or postfix) notation.
Calculate the total size of each program in bits under the following assumptions: The opcode is 4 bits long, each register number in an instruction is 4 bits long, and each memory address in an instruction is 16 bits long.
What conclusions can you draw from the above exercise? Use the following criteria as the basis of your comments: program size in instructions, program size in bits, average length of an instruction, number of registers, and usability of registers. Based on these criteria, which of the above machine types should be preferred for programs similar to the above?
Compare zero - , one - , two - , and three -

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!