Context Switch

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

I'm writing a context switch however when I change the optimisation level the required order of saving the registers changes.

Any advise on overcoming this.

Thanks

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

Is there away to read the status register using assembly of the UC3 proessor instead of reading it of the stack?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
#define AVR32_SR 0

mfsr  Rn, AVR32_SR  // move from system register
mtsr  AVR32_SR, Rn  // move to system register

Letting the smoke out since 1978

 

 

 

 

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

thanks, I might try using a software interupt to save the registers but I'll make a note of your suggestion should that not work.

Thanks digitalDan.

Could you tell me the location of the PC and LR???

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

All of the system register numbers accessible with mfsr and mtsr are listed in table 2-7 of the AVR32 Architecture Manual.

You access the PC and LR with any instruction that you would use with any other register: mov, ld, st, etc. Note that touching the PC with any instruction will cause its value to change; it is the program counter after all. :)

Letting the smoke out since 1978

 

 

 

 

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

Hello Dan, is there away of checking the optimisation level in the code?

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

At compile time? Maybe. At run time? I don't think so.

Letting the smoke out since 1978

 

 

 

 

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

At compile time you can use the gcc macros __OPTIMIZE__ and __OPTIMIZE_SIZE__. The first one is defined when compiling with any optimisation mode (-O1, -O2, -O3 and -Os), while the second one is only defined when compiling with -Os.

I don’t think it’s possible to distinguish between -O1, -O2 and -O3 at compile time or run time.