title: AVR interrupt - reset vectors handling in assembly
body: <p>I am using <strong>AVR ATmega16</strong> and I am trying to implement <em>a counter that counts seconds</em>. I am using <code>timer0</code> in order to produce an interrupt every 1/16 sec on a loop that repeats 16 times. Given the frequency of the microprocessor (<code>f=4Mhz</code>) and the <em>prescaler</em> value (<code>=1024</code>) I calculate that I need to give the timer an initial value of <code>12</code>.</p>
  
  <p>Here is the start of a sample code that I found on a textbook of mine:</p>
  
  <pre><code>.include "m16def.inc"
  .equ start = 12
  .equ loops = 16
  jmp reset
  reti (x16)    ;there will be needed a total of 16 reti's in order for the next
                ;instruction to be at 0x12 = 0d18 where the jmp instruction is placed at the 
                ;overflow interrupt handling routine of timer0
  jmp TIM0_OVF
  reti          ;other Handlers
  </code></pre>
  
  <p>Could please some explain what those two <code>reti</code> commands are actually doing? How do they work? What does the comment on the code mean?</p>
  
  <p>*Let me inform you that on ATmega16 the <code>TIMER0_OVF</code> vector is on the <code>program memory address = 0x12</code></p>