retagged by
25,410 views
78 78 votes

A certain processor supports only the immediate and the direct addressing modes. Which of the following programming language features cannot be implemented on this processor?

  1. Pointers
  2. Arrays
  3. Records
  4. Recursive procedures with local variable

5 Answers

Best answer
129 129 votes

Pointer access requires indirect addressing which can be simulated with indexed addressing or register indirect addressing but not with direct and immediate addressing. An array and record access needs a pointer access. So, options (A), (B) and (C) cannot be implemented on such a processor.

Now, to handle recursive procedures we need to use stack. A local variable inside the stack will be accessed as *$(SP+\text{offset})$ which is nothing but a pointer access and requires indirect addressing. Usually this is done by moving the SP value to Base register and then using Base Relative addressing to avoid unnecessary memory accesses for indirect addressing- but not possible with just direct and immediate addressing.

So, options (A), (B), (C) and (D) are correct.

edited by
12 12 votes
A.Pointers can be implemented only with the use of the indexed addressing mode or indirect addressing mode
B.Same for arrays as option A.
C.Records and arrays are typically types of structure so we will need atleast of the two addressing modes mentioned in option 1.
D.Recursion cant be implemented without stack as we cannot use any register to hold function calls as the no of the function calls would be limited by the number of registers available and we generally do independent compilation.So to use stack and access the data variables we need to use *(SP+offset) which is again a pointer application.

All four options are correct
3 3 votes

pointer require indirect addressing mode.Array and record need index addressing modes.

int foo(int a) {
  int b = 1 + a;
  int c = bar(b);
  return c;
}

 
int bar(int x) {
//do something
}

When bar  is done executing, it stores its return value in a register which  foo knows to check for the return value. So register addressing mode is required.

Hence the answer is A,B,C,D

edited by
2 2 votes

Pointer is a variable who holds address of different memory cell ,can change their values and much more.

int x = 10;
int y = 20;
int *p;

p = &x; // Now p holds the address of x
p = &y; // Now p holds the address of y

understand direct memory address now
    the memory address of the data is part of the instruction.
   Instruction: LOAD R1, 0x1000
   Meaning: "Load the value from the fixed address 0x1000 into register R1.
now lets say 
 we initialize int *p=0x1000
but we have fixed address we cant change it 

for indirect addressing mode

In indirect addressing mode, the instruction contains the location of the address, not the address of the final data. This creates the level of indirection that pointers require
Instruction: LOAD R1, [R2]  //Look at the address stored inside register R2. Go to that address and load the value you find there into register R1.

now this is what we needed here R2 can be pointer which holds address itself and data
now u can perform all operation of pointer here

now array need pointer,record also need pointer
and pointer can be implement by indirect addressing mode
since index addressing mode can able to perform indirec addressing mode

henc all needed indirect addressing mode or indexed can be used

1 1 vote

Question :- Processor with only Immediate and Direct Addressing Modes

  1. Limitation:
  • Immediate mode only handles fixed constants.
  • Direct mode only handles fixed, static memory addresses known at compile time.
  1. Why Recursive procedures with local variables CANNOT be implemented:
  • Recursion requires a runtime Stack to store distinct sets of local variables for each function call (Activation Records).
  • Accessing dynamic stack variables fundamentally requires Register-Indirect, Indexed, or Base-Register addressing modes (Effective Address = Stack Pointer + Offset).
  • Without a relative or indirect addressing mode, the processor cannot reference a dynamically changing stack frame location.
  1. Why Pointers, Arrays, and Records CAN be implemented:
  • Records: Field offsets are constant and pre-calculated at compile time, matching Direct mode.
  • Pointers & Arrays: While inefficient, they can be implemented using "Self-Modifying Code," where a program manually updates the target memory address embedded inside a Direct Addressing instruction before running it.
Answer:
Position:
Show:

Related questions

43 43 votes
6 answers 6 answers
16.6k
16.6k views
Kathleen asked Sep 23, 2014
16,595 views
The number of binary strings of $n$ zeros and $k$ ones in which no two ones are adjacent is$^{n-1}C_k$$^nC_k$$^nC_{k+1}$None of the above
52 52 votes
7 answers 7 answers
18.6k
18.6k views
Kathleen asked Sep 23, 2014
18,613 views
The main difference(s) between a CISC and a RISC processor is/are that a RISC processor typicallyhas fewer instructionshas fewer addressing modeshas more registersis easi...
22 22 votes
2 answers 2 answers
10.5k
10.5k views
Kathleen asked Sep 23, 2014
10,511 views
Arrange the following configuration for CPU in decreasing order of operating speeds:Hard wired control, Vertical microprogramming, Horizontal microprogramming.Hard wired ...
43 43 votes
5 answers 5 answers
11.2k
11.2k views
Kathleen asked Sep 23, 2014
11,210 views
Consider the following program fragment in the assembly language of a certain hypothetical processor. The processor has three general purpose registers $R1, R2$ and $R3$....