Consider the following Assertion (A) and Reason (R) regarding array translation in a generic load-store assembly language without auto-scaling addressing modes:
Assertion (A): To access the -th element of an array of 16-bit integers, the index must be multiplied by 2 before adding to the base address.
Reason (R): The memory is byte-addressable, meaning each address points to an 8-bit unit, so a 16-bit element spans 2 addressable units.
Which of the following is correct?
A
Step-by-Step Solution
Key idea: Effective address calculation requires scaling the element index by the element size in bytes.
Step 1: Evaluate Assertion (A). In a generic assembly without auto-scaling, the programmer must manually compute the byte offset. For 16-bit (2-byte) integers, the index must indeed be multiplied by 2. (A is True).
Step 2: Evaluate Reason (R). Modern main memory is byte-addressable. An 8-bit unit is 1 byte. A 16-bit integer occupies 2 bytes, hence it spans 2 addressable units. (R is True).
Step 3: Check the link. Does R explain A? Yes. The manual multiplication by 2 in A is required specifically <b>because</b> memory is byte-addressable and the element is 2 bytes wide (as stated in R).
Answer: Both A and R are true, and R is the correct explanation of A.