title: MSP430 Interrupt Overhead
body: <p>I am writing an ISR for the MSP430. It reads the volatile PxIFG register and copies it into a stack variable on the first instruction. Is there any overhead to an ISR jump or can I expect</p>
  
  <pre><code>__interrupt void SW_PRESSED_ISR(void)
  {
    unsigned short currnet_ifg = P4IFG;
  ...
  }
  </code></pre>
  
  <p>to compile to something like</p>
  
  <pre><code>... Register saving instructions
  JSR ...       // jump into ISR
  LD  P4IFG ... // load volatile register P4IFG value
  ...
  </code></pre>
  
  <p>I know that my ISR will work as intended if the first instruction after the ISR jump is the register load. My understanding is the MSP430 guarantees one instruction after the jump before it can be interrupted again. If the load isn't the first instruction after the jump I have the issue that I could be interrupted again before the P4IFG register is read and it's value may be changed to a different value which would be a problem.</p>
  
  <p>Is it reasonable for me to expect the compiler to place my load instruction immediately after that jump thus ensuring I will always get a copy of that register before another interrupt can change it?</p>
  
  <p>Thank you</p>