Question: Compare zero - , one - , two - , and three - address machines by writing programs to compute G = ( A x
Compare zero one two and threeaddress machines by writing programs to compute
G A x B C x DA 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 T T T etc. if necessary.
Also G is a memory location
The instructions available for use are as follows:
Address
Address
Address
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 eg A or T R refers to a register eg R you may assume up to registers and P and Q refer to either a register or a memory location.
Explanations of Instructions:
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, eg SUB: result second popped element first popped element
address: There is only one CPU register called Accumulator ACC LOAD X: ACC MX; STORE X: MX ACC; SUB X: ACC ACC MX
address: LOAD R X: R MX; STORE R X: MX R; SUB R P: R R P where P may be a register or a memory operand.
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 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 bits long, each register number in an instruction is bits long, and each memory address in an instruction is 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 threeaddress machines by writing programs to compute
G A x B C x DA 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 T T T etc. if necessary.
Also G is a memory location
The instructions available for use are as follows:
Address
Address
Address
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 eg A or T R refers to a register eg R you may assume up to registers and P and Q refer to either a register or a memory location.
Explanations of Instructions:
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, eg SUB: result second popped element first popped element
address: There is only one CPU register called Accumulator ACC LOAD X: ACC MX; STORE X: MX ACC; SUB X: ACC ACC MX
address: LOAD R X: R MX; STORE R X: MX R; SUB R P: R R P where P may be a register or a memory operand.
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 threeaddress machines by writing programs to compute
for each of the four machines. Assume
First write a program for each machine to compute the given expression. Hint: For the 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 bits long, each register number in an instruction is bits long, and each memory address in an instruction is 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?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
