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