All Exams Test series for 1 year @ ₹349 only
Question

Consider a processor P whose instruction set architecture is the load-store architecture. The instruction format is such that the first operand of any instruction is the destination operand.

Which one of the following sequences of instructions corresponds to the high-level language statement $Z = X + Y$ ?
Note: X, Y, and Z are memory operands. R0, R1, and R2 are registers.

The correct answer is
LOAD R0, X
LOAD R1, Y
ADD R2, R0, R1
STORE Z, R2

This question requires translating a high-level language statement into assembly code, considering a specific processor architecture and instruction format.

Load-Store Architecture Principles

In a load-store architecture, computations happen exclusively on data held within registers. Data must be explicitly moved between memory locations and registers using distinct LOAD and STORE instructions.

Instruction Format Constraints

The processor's specified instruction format designates the first operand in any instruction as the destination operand for the operation's result.

Translating High-Level Statement

The high-level statement to be translated is: \$Z = X + Y\$. In this context, X, Y, and Z are memory operands, while R0, R1, and R2 are registers.

Loading Data into Registers

To perform the addition, the values of X and Y must first be loaded from memory into registers. Adhering to the destination-as-first-operand rule:

  • Load the value of X from memory into register R0: $LOAD R0, X$
  • Load the value of Y from memory into register R1: $LOAD R1, Y$

Performing the Addition

With the values of X and Y now available in registers R0 and R1 respectively, the addition operation can be executed. The result must be stored in a designated destination register, such as R2:

$ADD R2, R0, R1$

Storing Result to Memory

The sum is now held in register R2. To complete the statement \$Z = X + Y\$, this result must be written back from register R2 to the memory location Z:

$STORE Z, R2$

Final Assembly Sequence

Combining these steps results in the complete assembly code sequence that accurately represents the high-level statement \$Z = X + Y\$ under the given architectural constraints:

$LOAD R0, X$
$LOAD R1, Y$
$ADD R2, R0, R1$
$STORE Z, R2$

Was this answer helpful?

Important Questions from Machine Instructions and Addressing Modes

  1. Consider the following program fragment in assembly language:

    mov ax, 0h

    mov cx, 0A h

    doloop:

    dec ax

    loop doloop

    What is the value of ax and cx registers after the completion of the doloop?

  2. Instruction AAA is used to
  3. Which of the following is/are part of an Instruction Set Architecture of a processor?
  4. The following language uses mnemonic OP codes

  5. What will be the hexadecimal value in the register ax (32-bit) after executing the following instructions ?

        mov al, 15

        mov ah, 15

        xor al, al

        mov cl, 3

        shr ax, cl

    Codes :

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App