Addressing-Modes
Question 1 |
Relative mode of addressing is most relevant to writing
coroutines | |
position – independent code | |
shareable code | |
interrupt handlers |
Question 2 |
Which of the following addressing modes permits relocation without any change whatsoever in the code?
Indirect addressing | |
Indexed addressing | |
Base register addressing | |
PC relative addressing |
Question 3 |
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?
Pointers | |
Arrays | |
Records | |
Recursive procedures with local variable | |
All the above |
B) Cannot be implemented because arrays need Register indexing.
C) Records also needs pointers which needs indirect addressing modes, so this also cannot be implemented.
D) Recursive procedures needs stack, and so it needs stack pointers which in turn needs indirect addressing. So this also cannot be implemented.
Question 4 |
In the absolute addressing mode
the operand is inside the instruction | |
the address of the operand is inside the instruction | |
the register containing the address of the operand is specified inside the instruction | |
the location of the operand is implicit |
The operand is inside the instruction --- absolute addressing.
The register containing the address of the operand is specified inside the instruction --- Register addressing.
The location of the operand is implicit --- Implicit addressing.
Question 5 |
The instruction format of a CPU is:
Mode and RegR together specify the operand. RegR specifies a CPU register and Mode specifies an addressing mode. In particular, Mode = 2 specifies that ‘the register RegR contains the address of the operand, after fetching the operand, the contents of RegR are incremented by 1’.
An instruction at memory location 2000 specifies Mode = 2 and the RegR refers to program counter (PC).
(a) What is the address of the operand?
(b) Assuming that this is a non-jump instruction, what are the contents of PC after the execution of this instruction?
Theory Explanation. |
Question 6 |
Which of the following statements about relative addressing mode is FALSE?
It enables reduced instruction size | |
It allows indexing of array elements with same instruction | |
It enables easy relocation of data | |
It enables faster address calculations than absolute addressing |
Question 7 |
The most relevant addressing mode to write position-independent codes is:
Direct mode | |
Indirect mode | |
Relative mode | |
Indexed mode |
Question 8 |
Which of the following addressing modes are suitable for program relocation at run time?
(i) Absolute addressing (ii) Based addressing (iii) Relative addressing (iv) Indirect addressing
(i) and (iv) | |
(i) and (ii) | |
(ii) and (iii) | |
(i), (ii) and (iv)
|
A fixed address in memory which indicates a location by specifying a distance from another location. In this displacement type addressing is preferred.
So, option A is false.
Based Addressing:
This scheme is used by computers to control access to memory. In this pointers are replaced by protected objects which can be executed by kernel (or) some other privileged process authors.
So, this is suitable for program relocation at runtime.
Relative Addressing:
The offset of the relative addressing is to allow reference to code both before and after the instruction.
This is also suitable.
Indirect Addressing:
Which leads to extra memory location which can be not suitable at run time.
This is not suitable.
→ Only Based Addressing and Relative Addressing are suitable.
Question 9 |
Consider the C struct defined below:
struct data { int marks [100]; char grade; int cnumber; }; struct data student;
The base address of student is available in register R1. The field student.grade can be accessed efficiently using
Post-increment addressing mode, (R1)+ | |
Pre-decrement addressing mode, -(R1) | |
Register direct addressing mode, R1 | |
Index addressing mode, X(R1), where X is an offset represented in 2’s complement 16-bit representation |
{
int marks[100];
char grade;
int cnumber;
}; struct data student
Base Address of student is available in R1.
So student.grade can be accessed efficiently by Relative Indexed Addressing Mode.
It is clearly mentioned X is the offset address to be summed with Base Address of R1.
Hence Index Addressing mode X(R1), where X is an offset represented in 2’s complement 16-bit representation.
⇾ Relative, Base Indexed & all subtypes of Indirect addressing modes are used with Arrays.
Question 10 |
Which of the following is/are true of the auto-increment addressing mode?
- I. It is useful in creating self-relocating code
II. If it is included in an Instruction Set Architecture, then an additional ALU is required for effective address calculation
III. The amount of increment depends on the size of the data item accessed
I only | |
II only | |
III Only | |
II and III only |
II. An additional ALU is not necessary for auto-increment. So this statement is wrong.
III. In auto-increment addressing mode the address where next data block to be stored is generated automatically depending upon the size of single data item required to store. This is based on pointer arithmetic. So this statement is true.
Hence option C is the answer.
Question 11 |
Register mode | |
Direct mode | |
Displacement mode | |
Immediate mode |
Single memory reference to access data.
No additional calculations to find the effective address of the operand.
Question 12 |
Index mode | |
Auto increment mode | |
Displacement mode | |
Register mode |
→The number of the index register and the constant value are included in the instruction code.
→Index Mode is used to access an array whose elements are in successive memory locations. The content of the instruction code, represents the starting address of the array and the value of the index register, and the index value of the current element.
→By incrementing or decrementing index register different element of the array can be accessed.