Zhu's ARM bare metal learning notes (V): ARMCPU working mode and registers

Publisher:温暖微笑Latest update time:2017-08-16 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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

symbolexplain
UserUser mode, most tasks are performed in this mode
FIQFast interrupt mode, when a higher priority interrupt occurs, this mode is entered
IRQInterrupt mode, when a low priority terminal is generated, this mode will be entered
SupervisorThis mode is entered when a reset or soft interrupt instruction is executed.
AbortAccess exception, this mode will be entered when access exception occurs
UndefUndefined instruction. This mode is entered when an undefined instruction is executed.
SystemSystem 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

ARM37 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. 
CPSR
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.


Reference address:Zhu's ARM bare metal learning notes (V): ARMCPU working mode and registers

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

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号