The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+27 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 (52k points)
retagged by | 3.7k views

2 Answers

+43 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+\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.

answered by Veteran (407k points)
edited by
@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.

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 :)
@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 .
@srestha  in indirect addressing mode we need two memory access ADD A,B ,(C) Is not correct example.
yes , I think
+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

answered by (105 points)
edited by

Related questions

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
49,530 questions
54,139 answers
71,068 users