A computer uses a small direct-mapped cache between the main memory and the processor. The cache has four $16$-bit words (the data field), and each word has an associated $13$-bit tag field. When a miss occurs during a read operation, the requested word is read from the main memory and sent to the processor. At the same time, it is copied into the cache, and its block number is stored in the associated tag.
Consider the following loop in a program where all instructions and operands are $16$ bits long:
$$ \begin{array}{|c|c|c|} \hline \text{LOOP} & \text{Add} & \text{(RI)+, RO} \\ \hline & \text{Decrement} & R2 \\ \hline & \text{BNE} & \text{LOOP} \\ \hline \end{array}$$
Main memory contents:
$$ \begin{array}{|c|c|c|} \hline \text{Address} & \text{Data} \\ \hline \text{054E} & \text{A03C} \\ \hline & \text{05D9} \\ \hline & \text{10D7}\\ \hline \end{array}$$
Assume that before this loop is entered, registers $R0, Rl$, and $R2$ contain $0, 054E$ and $3$, respectively. Also assume that the main memory contains the data shown in the above diagram of Main memory contents, where all entries are given in hexadecimal notation. The loop starts at location $\text{LOOP }= 02EC$.
What is the number of Main memory access at the end of the First pass through the loop?
- $3$
- $4$
- $6$
- $8$