Question

In: Computer Science

1.) Multiple Choice: Choose the correct letter choice. What is the correct sequence of instructions for...

1.) Multiple Choice: Choose the correct letter choice. What is the correct sequence of instructions for carrying out the calculation (A * B) - (A * C) on Stack Architecture.

Assume that:

  • A, B, C and D are memory locations
  • R1, R2, R3 are registers.
  • MUL
    • multiplies 2 operands and stores the result in the first operand in a 2 operand case
    • multiplies the second and third operands and stores the result in the first in a 3 operand case
  • SUB
    • subtracts the second operand from the first and stores result in the first in a 2 operand case
    • subtracts the third operand from the second and stores in the first operand in a 3 operand case
A.)

Push A

Push C

MUL

Pop D

Push B

MUL

Push D

SUB

Pop D

B.)

Load R1 A

MUL R2 R1 B

MUL R3 R1 C

Store R3 D

SUB R2 R2 D

Store R2

C.)

Load R1 A

Load R2 B

MUL R2 R1

MUL R3 R1

SUB R2 R3

Store R2 D

D.)

Load A

MUL C

Store D

Load A

Mul B

Sub D

Store D

E.)

Load R1 A

Load R2 B

MUL R2 R1

Load R3 C

MUL R3 R1

SUB R2 R3

Store R2 D

F.)

Push A

Push C

MUL

Push B

MUL

Push D

SUB

Pop D

Solutions

Expert Solution

Answer : OPTION D is correct . We will derive our answer as follows :

INSTRUCTION SET ARCHITECTURE :

There are three most common form of instruction set architecture :

1. STACK - The operands are implicitly on the Top of the stack .

2. ACCUMULATOR - One operator is implicitly present in the accumulator .

3. GENERAL PURPOSE REGISTER : All operands are explicitly mentioned , they are either register or memory locations .

Small Example of assembly code : C= A+B

Stack Accumulator General purpose register

PUSH A

PUSH B

ADD

POP C

LOAD A

ADD B

STORE C

LOAD R1 , A

ADD R1 , B

STORE R1 , C

4. RISC (Reduced Instruction Set computer) ARCHITECTURE :

The only memory access is through explicit LOAD / STORE .

LOAD R1 , A

LOAD R2 , B

ADD R3 , R1 , R2

STORE C , R3

The correct sequence of instruction to Calculate (A*B) - (A*C) on stack architecture is :

( A*B ) - ( A*C )

Option A :

PUSH A

PUSH C

MUL ( correct instuction till this point)

POP D ( no D is present here , so what to POP ? )

thus , this instruction set fails from this point , HENCE , INCORRECT OPTION

Option B :

LOAD R1 , A R1 <-- A (loaded A In register R1)

MUL R2 R1 B R2 <-- R1 * B (R1 is multiplied with B and stired in R2) means (A * B) = R2

MUL R3 R1 C R3 <-- R1 *C means ( A * C )

Store R3 D(incorrect)    R3 <-- D (memory D is stored in R3 , BUT , the correct should be , STORE D R3 )

HENCE , INCORRECT OPTION

Option C :

LOAD R1 A R1<-- A

LOAD R2 B R2<--B

MUL R2 R1 R2 <-- R2 * R1 , means , register R2 contains (A*B)

MUL R3 R1 R3 <-- R3 * R1 , R3 is empty and R1 contains A , we want C here to be multiplied with A , but we are not getting it , so this instruction becomes incoorect at this point

HENCE , INCORRECT OPTION.

Option D :

LOAD A ACC <-- A (A is loaded in accumulator)

MUL C ACC <-- ACC*C means (A*C) (C is multiplied by the value loaded in accumulator)

STORE D D <-- ACC (A*C) (the result loaded in accumulator is stored to memory location D )

LOAD A ACC <-- A

MUL B ACC <-- A*B

SUB D ACC <-- ACC - D , means , accumulator contains (A*B) and D contains (A*C)

this instruction will result in , (A*B) - (A*C)

HENCE, CORRECT OPTION

Option E :

LOAD R1 A R1<-- A

LOAD R2 B R2<-- B

MUL R2 R1 R2 <-- R1*R2 , i.e , (A*B)

LOAD R3 C R3 <-- C

MUL R3 R1 R3 <-- R3*R1 i.e (A*C)

SUB R2 R3 R2 <-- R2 - R3 i.e . (A*B) - (A*C)

STORE R2 D R2 <-- D means , D is to be stored in R2 . BUT , here memory location D is not used so it may contain no result or some default value . Thus we well not get our desired answer .

The correct instruction should be : STORE D R2 i.e. D <-- R2

HENCE , INCORRECT OPTION

Option F :

PUSH A STACK<--A

PUSH C STACK <-- C

MUL STACK <-- A*C

PUSH B STACK <-- B

MUL STACK <-- A*C*B (this instuction becomes incorrect here )

our aim is not to calculate A*B*C , HENCE , INCORRECT OPTION


Related Solutions

Multiple choice with rationale. Choose the letter of the correct answer and explain briefly why that...
Multiple choice with rationale. Choose the letter of the correct answer and explain briefly why that is the correct answer and why the other choices are incorrect. What modification in the Pol II enzyme leads to elongation of the polynucleotide chain? A. Acetylation B. Dephosphorylation C. Glucuronidation D. Phosphorylation 20. Which of the following molecular component/s are observed in the termination phase of protein synthesis? A. Amino acids, ATP B. Release factors, GTP C. Shine- Dalgarno sequence D. Aminoacyl-tRNA synthetase
Multiple –Choice: Choose the letter that best fits the statements provided. These are set of independent...
Multiple –Choice: Choose the letter that best fits the statements provided. These are set of independent organizations that eases the transfer of ownership of the product from the point of production to the point of consumptions. Promotion stratgey Product development strategy Channels of distribution strategy Pricing strategy The final activity in the distribution process of the goods along the channel process is actually on the_______________ channel. Manufacturer Distributor and wholesaler Retailer End User ABS- CBN Merchandizing of their top rating...
PROBLEM #1: (Multiple Choice) Choose the correct answer. We conduct a regression analysis to test the...
PROBLEM #1: (Multiple Choice) Choose the correct answer. We conduct a regression analysis to test the hypotheses β = 1 vs Ha: β = 1. The value of the test statistic is found to be 2.24 for sample sizes n=22. The p-value for this test is: ⑴ 0.01 < p-value < 0.025 ⑵ 0.02 < p-value < 0.05 ⑶ 0.0005 < p-value < 0.001 ⑷ 0.001 < p-value < 0.005 ⑸ None of the above
Multiple Choice: Choose the correct answer and report in your Word document. Which of the following...
Multiple Choice: Choose the correct answer and report in your Word document. Which of the following could be evaluated as anti-competitive using the per se rule? A. Three rival oil and gas firms propose to merge in a highly concentrated industry. B. Two oil and gas firms agree on who will win a new land lease before submitting bids. C. A large upstream oil and gas producer decides to purchase a downstream retailing firm. D. A new technological advancement allows...
PROBLEM #2: (Multiple Choice) Choose the correct answer. Suppose the systolic blood pressure is roughly a...
PROBLEM #2: (Multiple Choice) Choose the correct answer. Suppose the systolic blood pressure is roughly a linear function of the urinary sodium content and the slope is β1. For the test H0: vs. β1 = 0   vs   Ha: vs. β1 > 0 you reject the H0. Which of the following statements is true. ⑴ You can not make a Type I error. ⑵ You can not make a right decision. ⑶ You can not make a Type II error. ⑷...
Answers to Multiple-Choice Problems: A student wants to see if the correct answers to multiple choice...
Answers to Multiple-Choice Problems: A student wants to see if the correct answers to multiple choice problems are evenly distributed. She heard a rumor that if you don't know the answer, you should always pick C. In a sample of 100 multiple-choice questions from prior tests and quizzes, the distribution of correct answers are given in the table below. In all of these questions, there were four options {A, B, C, D}. Correct Answers (n = 100) A B C...
Choose the correct letter of the answer. 1. Mr. Su believes that his child developed the...
Choose the correct letter of the answer. 1. Mr. Su believes that his child developed the ways of thinking and behaving that make up a community’s culture through cooperative dialogues with more knowledgeable members of the society. Under which theory is Mr. Su’s belief anchored on? a. Ecological c. Psychoanalytic b. Ethological d. Sociocultural 2. Mary Rose found an opportunity to cheat with her seatmate. However, she is worried about getting caught by her professor. In Freud’s theory, Mary rose...
Answer the following statements as true or false, then select the correct multiple -choice answer:   1.   If...
Answer the following statements as true or false, then select the correct multiple -choice answer:   1.   If dividends are declared during the year the company would close the dividend account by debiting retained          earnings and crediting the dividend account.   2.   A company that forgets to recognize depreciation for the year understates its income and assets.   3.   Prepaid insurance expense will have a zero balance on the after closing trial balance.   4.   Retained earnings on an adjusted trial balance is the beginning retained earnings for...
1. Which of the following statements is correct concerning the Cash Budget? Multiple Choice The Cash...
1. Which of the following statements is correct concerning the Cash Budget? Multiple Choice The Cash Budget never includes cash disbursements from selling and administrative expenses, it only includes disbursements from product costs. The Cash Budget must be prepared before any other budgets. The Cash Budget does not contain any depreciation expenses. The ending cash balance is calculated by adding cash collected to the beginning cash balance for the period. 2. Hiss Corporation's activity for the last six months is...
Answer all of these questions with the right question number next to the correct choice (letter)....
Answer all of these questions with the right question number next to the correct choice (letter). 11) You are the CEO of Cute Pups Company, which makes blue jeans for dogs. Sales of your products are taking off so you decide to go public. However, without an MBA, you have no clue how to price and distribute your stock. You would probably hire the services of a(n): Investment banking house Savings and loan Commercial bank Mutual fund 12) The SEC...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT