Question

In: Computer Science

2. Given the Instruction sets for Machine-1, Machine-2 and Machine-3, write programs to calculate: P= ((B×C)...

2.

Given the Instruction sets for Machine-1, Machine-2 and Machine-3, write programs to calculate: P= ((B×C) + (A +D)) / (E - C × D) and comment on relative efficiency.

Machine-1: One address instructions

Machine-2: Two address instructions

Machine-3: Three address instructions

STORE X ; X<― [AC]

LOAD X ; AC<― [X]

MPY X ; AC<― [AC x X]

DIV X ; AC<― [AC / X]

ADD X ; AC<― [AC + X]

SUB X ; AC<― [AC -X]

X could be memory address/CPU register/variable

MOV X, Y ; X<― [Y]

MPY X, Y ; X<― [X x Y]

DIV X , Y ; X<― [X / Y]

ADD X, Y ; X<― [Y + X]

SUB X, Y ; X<― [X - Y]

X and Y could be memory addresses/CPU registers/variables

MOV X, Y ; X<― [Y]

MPY Z, X, Y ;Z<― [X x Y]

DIV Z, X , Y ; Z<― [X / Y]

ADD Z, X, Y ; Z<― [Y + X]

SUB Z, X, Y ; Z<― [X - Y]

X , Y and Z could be memory addresses/CPU registers/variables

…..

Solutions

Expert Solution

Given

One address machine instructions:

LOAD E AC<-- [E]

SUB C AC<--[AC - C]

MPY D AC<-- [AC D]

STORE T T <--AC

LOAD B AC<-- [B]

MPY    C AC<-- [AC C]

STORE P P <--AC

LOAD    A AC<-- [A]

ADD D AC<-- [AC+D]

ADD P AC<--[AC+P]

DIV T AC<--[AC/T]

STORE P P<--[AC]

Two address machine instructions:

MOV R1,E R1<--[E]

SUB R1,C   R1<--[R1-C]

MPY R1,D R1<--[R1D]

MOV R2,B    R2<--[B]

MPY R2,C R2<--[R2 C]

MOV R3,A R3<--[A]

ADD R3,D R3<--[R3+D]

ADD R2,R3 R2<--[R2+R3]

DIV R2,R1 R2<--R2/R1

MOV P,R2 P<--R2

Three address instructions:

SUB R1,E,C R1<--[E]-[C]

MPY R1,R1,D R1<--R1D

MPY R2,B,C R2<--BC

ADD R3,A,D R3<--A+D

ADD R2,R2,R3 R2<--R2+R3

DIV P,R2,R1 P<--R2/R1

EFFICIENCY IS IN THIS ORDER:

ONE ADDRESS >TWO ADDRESS >THREE ADDRESS

AS THERE IS INCREASE IN NO OF ADDRESSES THERE WILL BE INCREASE IN MEMORY ACCESSES

IF MEMORY ACCESSS INCREASES EFFICIENCY DECREASES .

FOR ONE ADDRES REQUIRES LESS NO OF MEMORY ACCESSES THAN TWO ADDRESS AND TWO ADDRESS REQUIRE LESS MEMORY ACCESSES THAN THREE ADDRESS

EFFICIENCY WILL BE REVERSE OF MEMORY ACCESSES THAT IS

ONE ADDRESS >TWO ADDRESS >THREE ADDRESS


Related Solutions

Write a C++ program Given fuzzy sets A and B, find complement A, A ∪ B,...
Write a C++ program Given fuzzy sets A and B, find complement A, A ∪ B, and A ∩ B A = {0.2 : a, 0.7 : b, 0.5 : c, 0.01 : k, 0.98 : z} and B = {0.42 : a, 0.6 : b, 0.5 : h, 0.1 : k, 0.44 : m, 0.8 : z}
Q. Let A, B independent events, with P(A) = 1/2 and P(B) = 2/3. Now C...
Q. Let A, B independent events, with P(A) = 1/2 and P(B) = 2/3. Now C be an event with P(C) = 1/4, and suppose that P(A|C) = 1/3, P(B|?̅) =7/9, P(A∩B|?̅) = 7/18. (a) Calculate the P(A∩B) (b) Calculate the P(A|?̅) and P(B|C) (c) Calculate the P(A∩B|C) (d) Show if P(A∩B|C) equals P(A|C)P(B|C) or not.
---------------------------------------------------------------------------------------------------------------- C++ //code a program for the following the given Instruction. Geometry Calculator 1. Calculate the...
---------------------------------------------------------------------------------------------------------------- C++ //code a program for the following the given Instruction. Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1-4): If the user enters 1, the program should ask for the radius of the circle and then display its area. Use 3.14159 for pi. #03   If the user enters 2, the program should ask for the length and width of...
67. Suppose that P(B) = 0.4, P(A|B) = 0.1 and P(A|B^c) = 0.9 (a) Calculate P(A)...
67. Suppose that P(B) = 0.4, P(A|B) = 0.1 and P(A|B^c) = 0.9 (a) Calculate P(A) (b) Calculate P(A|B) 71. Suppose a couple decides to have three children. Assume that the sex of each child is independent, and the probability of a girl is 0.48, the approximate figure in the US. (a) How many basic outcomes are there for this experiment? Are they equally likely? (b) What is the probability that the couple has at least one girl? 104. A...
Problem Description: Given Machine Instruction 1. LD R1, 50(R2) 2. ADD R3, R1, R4 3. LD...
Problem Description: Given Machine Instruction 1. LD R1, 50(R2) 2. ADD R3, R1, R4 3. LD R5, 100(R3) 4. MUL R6, R5, R7 5. ADD R1, R1, #100 6. SUB R2, R2, #8 Font type: Times New Roman and Size 12 Task to do: a) Draw the four-stage pipeline for the above Instruction. b) Calculate the total clock cycles for all the above-mentioned instructions need to be completed. c) Explain how to handle structural hazards the pipeline instruction. d) Explain...
A, B and C be sets. (a) Suppose that A ⊆ B and B ⊆ C....
A, B and C be sets. (a) Suppose that A ⊆ B and B ⊆ C. Does this mean that A ⊆ C? Prove your answer. Hint: to prove that A ⊆ C you must prove the implication, “for all x, if x ∈ A then x ∈ C.” (b) Suppose that A ∈ B and B ∈ C. Does this mean that A ∈ C? Give an example to prove that this does NOT always happen (and explain why...
True and False 1. The instruction register stores machine code for the instruction being executed. 2....
True and False 1. The instruction register stores machine code for the instruction being executed. 2. Before a digital computer may execute an instruction, the instruction code must be fetched from memory. 3. A pointer is a binary code for data in the arithmetic logic unit. 4. Von Neumann computer architecture stores data and instruction codes in the same memory. 5. Complex instruction set computers have instructions with greater speed than those in reduced instruction set computers.
On the overlap of two events, suppose two events A and B , P(A)=1/2, P(B)=2/3, but...
On the overlap of two events, suppose two events A and B , P(A)=1/2, P(B)=2/3, but we have no more information about the event, what are the maximum and minimum possible values of P(A/B)
3.Write the complete model for the following: (a) AR(P = 2)d=12 (b) MA(Q = 2)d=12 (c)...
3.Write the complete model for the following: (a) AR(P = 2)d=12 (b) MA(Q = 2)d=12 (c) ARMA(P = 1, Q = 2)d=12 (d) ARMA(P = 2, Q = 0)d=12 (e) ARMA(p = 0, q = 2) × (P = 1, Q = 2)d=12 (f) SARIMA(p = 1, d = 1q = 1) × (P = 1, D = 1, Q = 1)d=12 All I know is P, D, Q indicate seasonality. p,d,q do not. Some of these are mixed model...
(A) Let a,b,c∈Z. Prove that if gcd(a,b)=1 and a∣bc, then a∣c. (B) Let p ≥ 2....
(A) Let a,b,c∈Z. Prove that if gcd(a,b)=1 and a∣bc, then a∣c. (B) Let p ≥ 2. Prove that if 2p−1 is prime, then p must also be prime. (Abstract Algebra)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT