How to set program counter to illegal address while code is running ?Started by 6 years ago●3 replies●latest reply 6 years ago●217 views
I'm programming Infineon TC29x Aurix Tricore Microcontroller based embedded system in 'C' language.
I need to set program counter to illegal address, i.e. 0x00FF FFFC. Can this be done with assembly language instructions?
If yes, please instrument assembly language instruction that would set program counter to 0x00FF FFFC while code is running.
The usual technique in C involves a function pointer, something like
typedef void (*FUNC_PTR)(void);
FUNC_PTR pf = (FUNC_PTR)0x00FFFFFC;
But that is not an illegal address (depends upon the processor memory map). An illegal address is something different, like jumping to an unaligned value 0x1 or a value outside implemented memory.
That was very helpful!
I don't know about this specific processor nor your IDE, but if you can in-line some assembly code, then perhaps you can push the illegal address onto the return stack and then execute a return. This is more-or-less the standard way to implement a jump table in assembly for many processors, as few allow access to the PC.
Not all processors have the means to do this, and not all IDE's will let you in-line assembly code.