Thumb instructions can be seen as a subset of ARM instructions in compressed form. They are proposed to address the problem of code density1], and have a code density of 16 bits. Thumb is not a complete architecture, and you cannot expect the handler to only execute Thumb instructions without supporting the ARM instruction set. Therefore, Thumb instructions only need to support general functions, and when necessary, they can use the complete ARM instruction set, for example: all exceptions automatically enter the ARM state.
When writing Thumb instructions, you must first use the pseudo-instruction CODE16 declaration, and in the ARM instruction, you must use the BX instruction to jump to the Thumb instruction to switch the processor state. When writing ARM instructions, you can use the pseudo-instruction CODE32 declaration.
1]. Code density: the number of instructions contained in a unit of storage space. For example
ARM instructions are 32 bits, while Thumb instructions are 16 bits. If 32 ARM instructions can be placed in 1K of storage space, 64 Thumb instructions can be placed. Therefore, when storing Thunb instructions, the code density is high.
The difference between Thumb instruction set and ARM instruction set
The Thumb instruction set does not have coprocessor instructions, semaphore instructions, instructions for accessing CPSR or SPSR, multiplication and addition instructions, 64-bit multiplication instructions, etc., and the second operand of the instruction is restricted; except for the conditional execution function of jump instruction B, all other instructions are unconditionally executed; most Thumb data processing instructions use a 2-address format. The differences between the Thumb instruction set and the ARM instruction set are generally as follows:
Ø Jump instruction
Program relative transfers, especially conditional jumps, are more restricted in scope than jumps under ARM code. Jumping to a subroutine is an unconditional transfer.
Ø Data processing instructions
Data processing instructions operate on general registers, and in most cases the result of the operation must be placed in one of the operand registers rather than a third register.
Data processing operations are less frequent than in ARM state, and access to registers R8-R15 is subject to certain restrictions.
(Except for MOV and ADD instructions accessing registers R8-R15, other data processing instructions always update the ALU status flags in the CPSR)
Thumb data processing instructions that access registers R8-R15 cannot update the ALU status flags in the CPSR.
Ø Single register load and store instructions
In Thumb state, single register load and store instructions can only access registers R0-R7.
Ø Bulk register load and store instructions
The LDM and STM instructions can load or store any subset of the registers in the range R0-R7.
Previous article:Header file definitions and ARM instructions
Next article:ARM Basics: ARM Instructions MSR
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Bluetooth Module Hardware Design Guide
- 【Beetle ESP32-C3】Download CircuitPython
- How do you measure performance when developing software using a real-time operating system?
- Free evaluation - Topmicro intelligent display module (6) PIP small keyboard
- There are tens of millions of Bluetooth platforms on the market, which one do you like best?
- MicroPython Hands-on (10) - Learn MaixPy Neural Network KPU from scratch
- ZTE Hardware Written Test
- Where can I download the ST sensor package (PCB library)? It's actually very simple
- How to solve the problem that VS-rk3399 motherboard adb link cannot be established?
- MSP430 Flash Emulation Tool