A project that I'm working on involves a cycle accurate interrupt service routine. This routine is written in AVR Assembly where I just wrote:
.org oc1aadr rjmp INTRP
(to set up the IVT) And it worked perfectly well. However I had to use both C and assembly for this project, so I switched to GCC and after looking up some documentation, found that I just have to write the routine with a label:
Now the interrupt is working fine too, but the thing is that it now takes 3 cycles to enter into the ISR. On looking up the disassembler code, I saw that the IVT is like this:
+00000000: 940C002A JMP 0x0000002A Jump +00000002: 940C0047 JMP 0x00000047 Jump +00000004: 940C0047 JMP 0x00000047 Jump +00000006: 940C0047 JMP 0x00000047 Jump +00000008: 940C0047 JMP 0x00000047 Jump +0000000A: 940C0047 JMP 0x00000047 Jump +0000000C: 940C0047 JMP 0x00000047 Jump +0000000E: 940C0049 JMP 0x00000049 Jump +00000010: 940C0047 JMP 0x00000047 Jump
The JMP instruction takes 3 cycles unlike RJMP, which takes only 2. I've tried writing:
.org 0x0E rjmp INTRP
But still it won't work, I've also tried writing (.section .init0) before .org, but still no effect. So, is there any way I can change the instruction to RJMP? Note: Only the interrupt routine is written in assembly.
For my second question: Is there any difference in the clock cycles required by an instruction when using different compilers/assemblers? MY entire routine takes 3 clock cycles less using GCC compared to AVR Assembler. I don't know whether GCC depends on AVR Assembler or not, but is there a possibility of this happening? (I'm asking this based on the AVR simulator output).