interrupt routine register stacking

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

interrupt routine register stacking

7,450 Views
nanoGeek
Contributor I
I am running CW 6.2 and compiling for MCF5407.
 
I have an interrupt routine that needs to access the stack.  However, the compiler is saving several registers (D0, D1, D2, A0, & A1) to the stack at the beginning of the ISR.  Can I control which (if any) registers get saved to the stack?  If not, can I count on these registers always getting stacked as depicted below?
 
Code snippets follow:
 
<pre>
__declspec(interrupt)
void asm_exception_handler (void)
{
asm
   {
   /* Change to dBUG stack space */
   move.l  sp,__SP_INIT
   move.l  #__SP_INIT,sp
   move.l  a0,-(sp)
   lea     _contextr,a0
   movem.l d0-d7/a0-a7,(a0)    /* d0-d7/a0-a7 (a0/a7 are bad)   */
   move.l  (sp)+,r_a0(a0)      /* a0    */
the dissasembly view:
7E000D7C: 4FEFFFEC        lea      -20(a7),a7
7E000D80: 48D70307        movem.l  d0-d2/a0-a1,(a7)
7E000D84: 23CF00048188    move.l   a7,0x00048188 (0x48188)
7E000D8A: 2E7C00048188    movea.l  #295304,a7
7E000D90: 2F08            move.l   a0,-(a7)
7E000D92: 41F90004397A    lea      0x0004397A (0x4397a),a0
7E000D98: 48D0FFFF        movem.l  d0-d7/a0-a7,(a0)
7E000D9C: 215F0020        move.l   (a7)+,32(a0)
</pre>
Thanks,
 
Joe
 
Labels (1)
0 Kudos
7 Replies

1,119 Views
Technoman64
Contributor III
Using Codewarrior for the HC12 the following code can be used to contrl register stacking when entering a function. Do a search for "#praga" in Help for your Coldfire Codewarrior to see if this the same for target.
 
#pragma NO_ENTRY: No Entry CodeScope

Function

Syntax

"#pragma NO_ENTRY"

Synonym

None

Arguments

None

Default

None

Description

This pragma suppresses the generation of the entry code and is useful for inline assembler functions.

The code generated in a function with #pragma NO_ENTRY may not be safe. It is assumed that the user ensures stack use.

NOTE

Not all backends support this pragma. Some still generate entry code even if this pragma is specified.


Example

Listing 1.11 shows how to use the NO_ENTRY pragma (along with others) to avoid any generated code by the compiler. All code is written in inline assembler.

Listing 1.11 Blocking Compiler-generated Function Management Instructions
#pragma NO_ENTRY #pragma NO_EXIT #pragma NO_FRAME #pragma NO_RETURN void Func0(void) {   asm {/* no code should be writen by the compiler.*/     ...   } } 
See also

#pragma NO_EXIT 
#pragma NO_FRAME 
#pragma NO_RETURN 

0 Kudos

1,119 Views
nanoGeek
Contributor I
hmmm...I am asking a question about how the compiler (specifically, CW) deals with the stack w.r.t. interrupt functions.  Not to be pedestrian, but how is this off topic?
0 Kudos

1,119 Views
marc_paquette
Contributor V

I misread your post. I apologize for the confusion.

Thanks to Technoman64 for correctly reading the original post and a solution.

nanoGeek, let me know if you need more help.

Distracted by a miserable head cold,

Marc.

 

0 Kudos

1,119 Views
nanoGeek
Contributor I

Marc,

no problem.  Hope you get to feeling better soon.

As for this issue, CW for CF doesn't have the pragmas that Technoman64 indicated.  The only solutions I have found are:

1) move the ISR to a *.s file

2) use the function level asm option on the ISR:

__declspec(interrupt) asm void ISR(void){ .. }

(I was originally using the statement level asm directive)

Unfortunately, both options push one squarely into assembly.  For my current project, that isn't a problem since it is in assembly anyway.  Also, I can't really make a case for having mixed C/ASM in this situation since it is a pretty rare case that you would want the ISR to access the intterupt stack frame anyway (this ISR is for processing TRACE and ILLOP interrupts as part of a Dbug code port).

Thanks!

 

0 Kudos

1,119 Views
marc_paquette
Contributor V
The compiler engineer confirms it: the ColdFire compiler currently doesn't offer any options to control register saving and restoring for ISRs. I'll pass your question along to my colleagues as a request to add such a feature. You can also throw your voice in formally by submitting a service request:
 
To submit a service request:

1. Go to http://freescale.com/support

2. In the Develop column, click "Technical Support."

3. Click "Submit a service request."
 
Marc.
0 Kudos

1,119 Views
Alban
Senior Contributor II

[Insert sarcastic participation here]

Euh, for general questions on how the forum works, posts should be on the General Use Board.

[End of sarcastic participation]

Question is awright here, otherwise Mod would have moved it to the appropriate board. Isn't it what the Mod should do ? :smileyhappy:
Unfortunately I don't have a clue and can't have your subject progressing.

If your project is blocked or absolutely need an answer, please Submit a Service Request against CodeWarrior as it's the 'formal' system with guarantee of service... http://www.freescale.com/TechSupport shows a dashboard of possibilities.

Cheers,
Alban. - {Sacartic Mod}

0 Kudos

1,119 Views
marc_paquette
Contributor V

This post is off-topic for this forum. Have you tried posting this question to the new 68K/Coldfire forum?

http://forums.freescale.com/freescale/board?board.id=CFCOMM

Marc.

0 Kudos