3.7k views

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
retagged | 3.7k views

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
0
@Srestha Di, are you talking about the direct addressing mode in the article?
0
yes , u can
0
Di, I understand what you are saying that the instructions contain a mode field which specifies the addressing mode but I am still not getting how to move forward to the next location without using any other addressing mode except indirect addressing. I think in that case we'll have to dereference the pointers to the subsequent locations every time.
+1
@Sukannya

In indirect addressing mode, we no need to go next location

But we need to fetch some value from some memory address

So, say B=4

and C=1000

So, now we go to memory location 1000 and fetch value

Say memory location 1000 contains 5

So, result in A will be (4+5)=9

Now, A will contain value 9
0

0

@Sukannya

yes here u r right

@ Soumya29

u r just telling opposite

0
Yeah.. ryt ... Got it .i was telling something else :)
0
@bharti loyal when we pass  pointer we pass address of location of variable not address of pointer

address of pointer is passed when we use **p in formal parameter .
0
@srestha  in indirect addressing mode we need two memory access ADD A,B ,(C) Is not correct example.
0
yes , I think

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.

edited

1
2