Thanks, Now I managed to solve it for now, The problem is now I had to determine LDR and STR and the destination register for that instructions,
I have used some simple methods to detect LDR and STR like this,
volatile uint32_t inst = (*(unsigned int *)sp[6]) & 0xFFFF;
if(inst == 0x6088)
{
//it's an STR instrcution
}
if(inst == 0x680A)
{
//it's an LDR
}
The problem with this approach is that every Reg has a different opcode, so I should write all the cases that would slow down the things
Also I have set the return answer using this method
sp[2] = calculated value;
If the used address in some other parts of the code changes and uses another register, it would fail,
So the question is how to detect LDR and STR instruction with the used Register efficiently, do we have a better way?