retagged by
15,413 views
54 votes
54 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
retagged by

3 Answers

Best answer
90 votes
90 votes

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
4 votes
4 votes
A.Pointers can be implemented only with the use of the indexed addressing mode or indirect addressing mode
B.Same for arrays as option A.
C.Records and arrays are typically types of structure so we will need atleast of the two addressing modes mentioned in option 1.
D.Recursion cant be implemented without stack as we cannot use any register to hold function calls as the no of the function calls would be limited by the number of registers available and we generally do independent compilation.So to use stack and access the data variables we need to use *(SP+offset) which is again a pointer application.

All four options are correct
3 votes
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

edited by
Answer:

Related questions

35 votes
35 votes
4 answers
1
Kathleen asked Sep 23, 2014
8,961 views
The main difference(s) between a CISC and a RISC processor is/are that a RISC processor typicallyhas fewer instructionshas fewer addressing modeshas more registersis easi...
37 votes
37 votes
5 answers
2
Kathleen asked Sep 23, 2014
14,996 views
Which of the following sets of component(s) is/are sufficient to implement any arbitrary Boolean function?XOR gates, NOT gates$2$ to $1$ multiplexersAND gates, XOR gatesT...
29 votes
29 votes
2 answers
3
Kathleen asked Sep 23, 2014
11,465 views
If $L1$ is context free language and $L2$ is a regular language which of the following is/are false?$L1-L2$ is not context free$L1 \cap L2$ is context free$\sim L1$ is co...