Assembler interrupt routines in C

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi folks,
I want to (äh I must :( ) write an assember routine for the external Interrupt 0. It mus react as fast as possible, but the processor will be stopped after this routine, therefore, there's no need for me to take care of the stack stuff.... :D

How can I tell the linker, that it should take my assembly program for INT0 ? No problem to include "normal" assembler functions into the AVRGCC, but interrupts seems to be very difficult.

It would also help me, if I can disable the prolog and directly start with inline assembler (just 3 or 4 instructions)

Thanks !
Andreas

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cant you declare the ISR in C, add the "naked" attribute (so no preamble to push things to the stack) then have the body of the function as one long asm() statement?

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The "naked" attribute would allow you to create an ISR without any prologue, and you could insert some inline assembly there. Try something like this macro:

#define NAKED_ISR(vector) \
void vector (void) __attribute__ ((naked)); \
void vector (void)

And then create an instance of a "naked" ISR like this:

NAKED_ISR(INT0_vect)
{
   // There is *no* intrinsic register save before this point.

   // insert code here.

   //There is *no* intrinsic register restore / RETI after this point
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In assembly, it's not that different at all:

#include 

.global INT0_vect
INT0_vect:
	hcf	;; halt and catch fire :-)

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot folks.....
I also had "forgotten" to name it xyz.S instead I used xyz.s .... :oops:

Andreas