2.2k 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 | 2.2k 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+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.
selected
@Srestha Di, what I am saying is Dhruv's question was can an array be implemented with just using indirect addressing mode? So, if that is the only permissible mode then to access array elements, we need some way to specify the offset so that we can access the next element but only indirect can't do so I think.
In opcode field it is already defined how offset will be expressed in instruction
So, array could be implemented using indirect addressing
@Srestha Di, are you talking about the direct addressing mode in the article?
yes , u can
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.

@sukannya I think your point of confusion is Add #2, R2. See this is not immediate addressing, This is just a simple arithmetic operation that we used to simulate indexing addressing.

@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

@Sukannya

yes here u r right

@ Soumya29

u r just telling opposite

Yeah.. ryt ... Got it .i was telling something else :)

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.