The memory locations 1000 and 1010 have data values 18 and 16 respectively before the following program is executed. MOVI R_0, 1 ; Move immediate LOAD R_0, 1000(R_0) ; Load from memory ADDI R_0, 1000 ; Add immediate STOREI 0(R_0), 20 ; Store immediate Which of the statements below is TRUE after the program is executed? A. Memory location 1000 has value 20 B. Memory location 1020 has value 20 C. Memory location 1002 has value 20 D. Memory location 1001 has value 20
GATE 2006 · Computer Organization and Architecture · Addressing Modes · medium
Answer: Memory location 1001 has value 20 after execution. Answer: D.
- MOVI R_0, 1: Immediate mode: the constant 1 is loaded directly into R_0. No memory access. R_0 = 1.
- LOAD R_0, 1000(R_0): Effective address = 1000 + R_0 = 1000 + 1 = 1001. The value at mem[1001] is loaded into R_0. mem[1001] holds its initial value of 1 (not 18 or 16, which are at 1000 and 1010). So R_0 = 1.
- ADDI R_0, 1000: Add immediate 1000 to R_0. R_0 = 1 + 1000 = 1001.
- STOREI 0(R_0), 20: Store the immediate value 20 at effective address 0+R_0 = 0+1001 = 1001. So mem[1001] = 20. Memory locations 1000 and 1010 are unchanged at 18 and 16.