We are using ARM Toolset , Toolchain MDK-ARM Professional Version 5.21a and Device is LPC2388.
We are trying to create a "undefined instruction exception" on a "BL" instruction in the thumb mode. When we tried to alter the H fllag in the first part of the instruction, we were unable to single step through the instruction as the instruction decoding was not successful. But when we moved the H flag altering to the second part of the instruction, the single stepping went through the instruction and proceeded to the next.
I wonder how on both the occasions the undefined instruction exception was created. This might cause a controller reliability issue in a mission critical system.
Can someone explain why the undefined instruction exception was not entered in our case and suggest a way of creating undef-exception on a BL instruction.
Thanks in advance.
Hello Robert
Thanks for your reply.
We managed to create a "Undefined instruction exception" and inside the exception handler, while the processor (CPSR)is still in "undefined" state and while so we are trying to execute a "BX" instruction.
With R0 containing 0x1B8 as the adddress, we execute a "BX R0" instruction. But to our surprise, we see the execution goes to 0x1C4. We had tried "MOV R15, R0". But that also results the same. To our surprise we note that register R4 is also getting modified when we execute the BX instruction.
FYI, the code at location 0x1B8 is a thumb instruction, as we are building the application code in thumb mode.
Can you or someone explain why PC = 0x1C4 instead of 0x1B8 that we wrote.
Do we need to take care of executing few other instructions inside our Undef_handler and leave the processor in a defined state to get the BX instruction execution correctly?
Please help us resolve this issue.
Thanks