The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+19 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


asked in CO & Architecture by Veteran (69k points)
retagged by | 2.2k views

2 Answers

+32 votes
Best answer
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.
answered by Veteran (346k points)
selected by
@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.


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

But we need to fetch some value from some memory address

Say ADD A, B,(C)

Here C is memory address and B is register 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

@Soumya29, see the example of immediate addressing mode in this link


yes here u r right

@ Soumya29

u r just telling opposite

Add #2, R2

is immediate addressing but not indirect addressing mode

Yeah.. ryt ... Got it .i was telling something else :)
+2 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

answered by (121 points)
edited by

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

33,705 questions
40,252 answers
38,862 users