How can I perform unconditional jump to random address in flash? I know about goto statement but I read that its not a good way to achieve this. So how can I do it?
Use a function pointer, assign is a random value (of the right range) and then call that function pointer.
Something like this is routinely done by people who sell encrypted commercial software. Once the software detects tampering, it fly's off.
The micro-controller can transfer control to wherever, in C you can use things line function pointers (see qsort)
The more important question is WHAT are you trying to achieve or solve by doing this? Perhaps there is a better approach.
Actually I am trying to perform IAP(in application programming) to achieve OTA via Wifi. So I have decided to map memory and after programming jump to new code memory, for this I was thinking of implementing a check to know where to jump, hence was thinking how do I perform unconditional jump..
"how do I perform unconditional jump.. "
that's different from performing a random jump.
take a look at the start-up file as it may give you a hint - it is fairly easy.
Typically with IAP the secondary app image contains a full vector table so you have access to interrupts, etc. Normally one enters through the Reset_Handler, as jumping to main() directly causes issue with the statics not being correctly initialized.
Retrieving data ...