From the CPU's point of view, how does it distinguish an assembly code is an ARM code or a Thumb code?
Is there some signal bit represent the code is ARM or Thumb code, this is just my guess.
Thanks very much for your answer.
And I want to ask one more question is that the CPU how to distinguish thumb and thumb-2 code?
Because thumb-2 code has 16-bit length and 32-bit length code.
A little bit terminology first. Thumb-2 isn't an instruction set, but an extension to Thumb. So in that sense, it doesn't need to distinguish between Thumb and Thumb-2 instructions. The processor either support Thumb-2, or it doesn't.
Whether a Thumb instruction is 16-bit or 32-bit is part of the encoding, specifically the upper bits of the first 16-bit chunk.
Take a look at sections A6.2 and A6.3 of the ARMv7-A/R Architecture Reference Manual.
ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition