The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+23 votes
3.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
asked in CO & Architecture by Veteran (59.7k points)
retagged by | 3.2k views

2 Answers

+38 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 (370k points)
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

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
0

@Soumya29, see the example of immediate addressing mode in this link http://web.cs.iastate.edu/~prabhu/Tutorial/PIPELINE/addressMode.html

0

@Sukannya

yes here u r right

@ Soumya29

u r just telling opposite

Add #2, R2

is immediate addressing but not indirect addressing mode

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
+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 (103 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

44,491 questions
49,940 answers
165,706 comments
65,911 users