Question.3
An ISR processes incoming UART bytes into a buffer. Two approaches:
Approach A — index-based:
buf[write_idx++] = UART_DR;
Approach B — pointer-based:
*write_ptr++ = UART_DR;
Which is better suited for an ISR?
Select Answer
Both are equivalent — the compiler generates identical code
Approach B — pointer increment is a single operation; index requires base + offset calculation
+
Approach A — indices are safer because they can be bounds-checked easily
Neither — ISRs shouldn't write to buffers directly