GATE CS 2021 Set 1 | Question 65

Computer Organization & Architecture › Machine Instructions · NAT · 2 marks · Answer: 50

  1. Question 65Computer Organization & Architecturenat2 marks
    Consider the following instruction sequence where registers R1, R2 and R3 are general purpose and MEMORY[X] denotes the content at the memory location X.
    Instruction        Semantics                 Size (bytes)
    MOV R1, (5000)     R1 <- MEMORY[5000]            4
    MOV R2, (R3)       R2 <- MEMORY[R3]              4
    ADD R2, R1         R2 <- R1 + R2                 2
    MOV (R3), R2       MEMORY[R3] <- R2              4
    INC R3             R3 <- R3 + 1                  2
    DEC R1             R1 <- R1 - 1                  2
    BNZ 1004           Branch if not zero to addr    2
    HALT               Stop                          1
    Assume that the content of memory location 5000 is 10, and the content of register R3 is 3000. The content of each of the memory locations from 3000 to 3010 is 50. The instruction sequence starts from memory location 1000. All the numbers are in decimal format. Assume that the memory is byte addressable. After the execution of the program, the content of memory location 3010 is ______.

    Answer: 50

    Solution

    R1 starts at 10 and the loop (BNZ to address 1004, the second instruction) runs while R1 is non-zero, writing to MEMORY[R3] as R3 increments from 3000. The loop body executes for R3 = 3000..3009 (10 iterations) and then stops; MEMORY[3010] is never written and stays 50.

More GATE PYQ on Machine Instructions

All GATE CS Computer Organization & Architecture PYQ →

Attempt GATE CS 2021 Set 1 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →