This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
One of my customer is requesting code sinppet which could be added in illegal instruction Handler, to find out the location where exactly illegal operation had happened by fetching the values of PC or RPC from stack.
From my understanding, Illegal Instruction trap interrupt is executed when invalid instruction is decoded. This cannot be blocked during execution. Illegal instruction Trap will save the return address in stack and thus we would be able to corrupted address location from the stack. (with ref to SRU430d , section 3.6)
To retrieve the address where the invalid instruction is executed, We need to add the code in the ILLEGAL_ISR to pop the RPC register by using the POP RPC instruction. After popping the RPC register, how to move its value to variable ? Since there is no MOV or MOVL instruction to access the RPC, i am not able to fetch the its register value.
Can anyone suggest me, How to get the invalid instruction address from RPC ?
Regards
Narayanan
Narayanan,
when you get an Illegal ISR, the PC value (pointing to the instruction after the illegal instruction) is saved on the stack. The RPC register value is not saved on the stack and you can ignore it.
To retrieve the saved PC value, simply read the stack location as follows:
IllegalISR:
MOVL ACC,*-SP[2] ; ACC = return PC value from stack
....
Note: The above instruction will work regardless if the stack is aligned or not as long as you perform a 32-bit read operation like the above.
Hope it helps.
Cheers,
Alex T.
Hi Alex,
Thanks for your info. I already ask the customer to
POP ACC
MOVL @_i, ACC
regards
Narayanan
If you're in a debugging situation (debugger attached and you can halt the code) you can also put an ESTOP0 in the ISR to halt the processor followed by an IRET (return from interrupt).
When the ITRAP is taken you will halt at the ESTOP0 (assumes a debugger is attached - otherwise this is a NOP). Then you can single step the IRET and the PC will go back to where the ITRAP was taken.
Regards
Lori
Hello XELA,
I am using a TMS320F28335, which according to TI's website has the same instruction set as the F2808.
I received an illegal op code error from the compiler when I tried to add asm("MOVL ACC,*-SP[2] ") to ILLEGAL_ISR. Please see code and compiler output below.
Stephen
interrupt void ILLEGAL_ISR(void) // Illegal operation TRAP
{
// Insert ISR Code here
asm("MOVL ACC,*-SP[2]");
// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
asm(" ESTOP0");
}
"../HAL/DSP2833x/DSP2833x_DefaultIsr.c"
"DSP2833x_DefaultIsr.asm", ERROR! at line 477: [E0002] Invalid mnemonic
1 Assembly Error, No Assembly Warnings
specification
MOVL ACC,*-SP[2]
Errors in Source - Assembler Aborted
gmake: *** [HAL/DSP2833x/DSP2833x_DefaultIsr.obj] Error 1
>> Compilation failure
**** Build Finished ****