ARM's convention
byte 8bits
halfword 16bits
word 32bits
Instruction set provided by ARM Core
ARM instruction set 32 bits
Thumb instruction set 16 bits
Thumb2 instruction set 16&32 bits
Seven working modes of ARM CPU
symbol | explain |
---|---|
User | User mode, most tasks are performed in this mode |
FIQ | Fast interrupt mode, when a higher priority interrupt occurs, this mode is entered |
IRQ | Interrupt mode, when a low priority terminal is generated, this mode will be entered |
Supervisor | This mode is entered when a reset or soft interrupt instruction is executed. |
Abort | Access exception, this mode will be entered when access exception occurs |
Undef | Undefined instruction. This mode is entered when an undefined instruction is executed. |
System | System mode, a privileged mode that uses the same register set as User mode |
Except for User mode, which is normal mode, the other 6 modes are Privilege mode. Among the privileged modes, except Sys mode, the other 5 modes are exception modes.
The switching between the modes can be done manually by the programmer through code (writing CPSR register), or the CPU can automatically switch under certain circumstances.
The CPU registers that can be accessed in different modes are different.
ARM CPU's 37 registers
The CPU registers that can be accessed in different modes are different. The black part in the figure above is the register that can be accessed in user mode. The black part in FIQ is the same as in User mode, and r0 accessed in FIQ mode is the same register as r0 in User mode, while the gray r8 is the register unique to FIQ mode. Similarly, r13 and r14 under IRQ are also private registers in their own mode and can only be accessed in their own mode.
ARM has 37 registers, all of which are 32 bits long.
Of the 37 registers, 30 are general-purpose, 1 is fixed as PC, 1 is fixed as CPSR, and 5 are fixed as SPSR in 5 exception modes.
The CPSR register is used to indicate certain status information of the CPU. The meaning of each bit is as shown in the figure below.
The SPSR register is used to save the data in the CPSR when entering the exception mode, and to restore the data in the CPSR when returning to the user mode from the exception mode.
The r15 register is also called the pc (program control) register, which is the program pointer. Wherever the pc points to, the CPU will execute the instruction pointed to by the address.
ARM exception handling
All processes outside of normal operation are called exceptions. Interrupts are also a type of exception.
When an exception occurs, the CPU will automatically jump to a fixed address to run. This fixed address is the terminal vector table. The interrupt vector table stores the program addresses to which all exceptions should jump. The exception vector table is the support provided by hardware to software for handling exceptions.
ARM exception handling process: When an exception occurs, first copy CPSR to SPSR_,
then set the appropriate CPSR bit, change the processor working mode, enter ARM state, perform exception handling, save the return address LR_ and set PC to the corresponding exception vector.
When the exception returns, restore CPSR from SPSR_ and PC from LR_ .
These operations can only be performed in ARM state.
Previous article:Zhu's ARM bare metal learning notes (VII): Calling C language to write startup code in assembly
Next article:Zhu's ARM bare metal learning notes (VI): ARM assembly
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- Sandia Labs develops battery failure early warning technology to detect battery failures faster
- [Starting at 13:30 pm] TI wireless connectivity product series application design guidance, online hands-on demo
- Inductance and Q value of transformer
- MSP430 ADC analog-to-digital routines
- Shenying series SY-Y1000 intelligent partition long-range laser perimeter warning radar
- The nonlinearity of the diode will cause some new waveforms to be generated. What is the underlying formation principle? Who can explain it to me?
- STM32F030 AD signal acquisition
- Does anyone have a working stm32F7 or H7 fmc interface lcd driver? I've been having a lot of trouble with it recently.
- The output data of the ADC chip is incorrect no matter how I process it. Please help.
- Some knowledge about optical splitters
- [NXP Rapid IoT Review] Unboxing Test