Thumb mode instructions are 2 bytes and ARM mode instructions are 4 bytes. the screenshot is a disassembly of thumb mode instructions. why do I see 4 byte instructions mixed with 2byte instructions?? can someone explain this?
thank you in advance.
These directives do not change the instruction set state of the processor. To do this, you must use an appropriate instruction, for example BX or BLX to change between ARM and Thumb states when performing a branch.
The Thumb instruction set is a subset of the most commonly used 32-bit ARM instructions. Thumb instructions are each 16 bits long, and have a corresponding 32-bit ARM instruction that has the same effect on the processor model.
ARM instructions are 32 bits wide. Thumb instructions are 16 or 32-bits wide. The ARM instruction set is a set of 32-bit instructions providing a comprehensive range of operations. ARMv4T and later define a 16-bit instruction set called Thumb.
Thumb-2 is an enhancement to the 16-bit Thumb instruction set. It adds 32-bit instructions that can be freely intermixed with 16-bit instructions in a program. The additional 32-bit instructions enable Thumb-2 to cover the functionality of the ARM instruction set.
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471i/CHDFEDDB.html
or pdf
http://infocenter.arm.com/help/topic/com.arm.doc.dui0471i/DUI0471I_developing_for_arm_processors.pdf
Thumb-2 technology is available in the ARMv6T2 and later architectures. Thumb-2 technology is a major enhancement to the Thumb instruction set. It adds 32-bit instructions that can be freely intermixed with 16-bit instructions in a program. The additional 32-bit encoded Thumb instructions enable Thumb to cover most of the functionality of the ARM instruction set. The availability of 16-bit and 32-bit instructions enables Thumb-2 technology to combine the code density of earlier versions of Thumb with the performance of the ARM instruction set.
Cortex M micros can run only in Thumb-2 mode, which is something in between thumb and ARM modes. Thumbs-2 instruction set includes 16 and 32 bit instructions and processor don't need switch modes to execute both types of instructions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With