“ Yes saving the current cpsr into spsr_undef is not the way to do it. On exception or interrupt the cpsr is automatically stored to spsr in the bank belonging to the exception or interrupt. Then the cpu sets the needed register bank in the cpsr. “
Yes, but this, if I'm not mistaken, only happens if the processor provides an exception for a certain event. In fact, what you say happens to me when I generate a given abortion for example. But here the situation is different because for the division by zero the processor of the TMS570 does not provide for the activation of any exception in fact, as I said in previous posts, in the asm files that manage the divisions it is explicitly reported that the division by zero simply returns zero. Then always in these files there is a note in which if you want to activate an exception, instead of returning zero, you have to edit the file. I made these changes and they would be what I told you in the previous post and they are as follows. So when I make these changes I’m not yet in a handler but I’m still within the split function. What I do is this:
When divider by zero raises i want to generate an undef exception so i have to save actual cpsr to spsr_undef and actual PC to R14_undef.
To do this i have to:
Inside division function
- save PC
- switch to undef mode
- save cpsr to spsr_undef
- save pc to R14 undef
- mov pc, #addr_undef_exception
AFTER inside isr i restore the System.
This behaviour works good when inside main i Write directly a/b, i able to restore the System and go to nextfunc():
Int main()
{
Uint32 a=1;
Uint32 b=0;
Uint32 c=0;
C=a/b;<———
Nextfunc();
}
My problem is Only when my divison is inside a nested function.