119k views
4 votes
To access stack-passed parameters in a procedure, which addressing mode is used?

a) Indexed Operands
b) Register Direct
c) Base + Offset
d) Register Indirect

User Arun Blr
by
7.5k points

1 Answer

4 votes

Final answer:

option c,The addressing mode used to access stack-passed parameters in a procedure is 'Base + Offset', which involves using a register as a base point and adding an offset to access the specific memory location of the parameter.

Step-by-step explanation:

To access stack-passed parameters in a procedure, the addressing mode used is Base + Offset. This mode is typically used when a function’s arguments are passed on the stack. In this scenario, the 'base' is usually a register that holds the address of the stack frame, and the 'offset' is a constant value that specifies the distance from the base where the parameter is located.

For example, in x86 assembly, if the 'ebp' register points to the base of the current stack frame, then an operand with an addressing mode such as '[ebp + 8]' might be used to access a parameter passed on the stack. This is because '[ebp + 8]' refers to the memory location 8 bytes beyond the base pointer ‘ebp’, which could be where the first parameter is stored if the return address and the previous frame pointer take up 4 bytes each on the stack.

The correct addressing mode to access stack-passed parameters in a procedure is Register Indirect.

In this mode, the processor uses a register to indirectly access the memory location holding the parameter value.

For example, if the parameter is stored at the top of the stack, the stack pointer register can be used to indirectly access and retrieve the value.

User Sanjiv
by
7.7k points