ARM stack study notes

Publisher:影子猎人Latest update time:2015-04-10 Source: 21icKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
 The following is what I learned about the stack when studying ARM instructions:

1. Register R13 is often used as a stack pointer in ARM instructions

2. For the R13 register, it corresponds to 6 different physical registers, one of which is shared by the user mode and the system mode, and the other 5 physical registers correspond to the other 5 different operating modes. The following symbols are used to distinguish different physical registers:

R13_

Among them, mode is one of the following modes: usr, fiq, irq, svc, abt, und.

3. Register R13 is often used as a stack pointer in ARM instructions, but this is just a customary usage. Users can also use other registers as stack pointers. In the Thumb instruction set, some instructions require the use of R13 as a stack pointer. Since each operating mode of the processor has its own independent physical register R13, in the initialization part of the user application, it is generally necessary to initialize R13 in each mode to point to the stack space of the operating mode. In this way, when the program enters the exception mode, the registers that need to be protected can be placed in the stack pointed to by R13, and when the program returns from the exception mode, it is restored from the corresponding stack. This method can ensure the normal execution of the program after the exception occurs.

4. There are four types of stacks: A stack is a data structure that works in a First In Last Out (FILO) manner, using a special register called the stack pointer to indicate the current operation position. The stack pointer always points to the top of the stack.

When the stack pointer points to the last data pushed into the stack, it is called a full stack, and when the stack pointer points to the next empty location where data will be placed, it is called an empty stack.

At the same time, according to the way the stack is generated, it can be divided into ascending stack and descending stack. When the stack is generated from low address to high address, it is called ascending stack, and when the stack is generated from high address to low address, it is called descending stack. In this way, there are four types of stack working modes, and ARM microprocessors support these four types of stack working modes, namely:

◎ Full descending full descending stack

The stack header is a high address, and the stack grows toward lower addresses. The stack pointer always points to the last element of the stack (the last element is the last data pushed in).

The ARM-Thumb procedure call standard and the ARM and Thumb C/C++ compilers always use a Full descending type stack.

◎ Full ascending full increment stack

The stack header is a low address, and the stack grows toward higher addresses. The stack pointer always points to the last element of the stack (the last element is the last data pushed in).

◎ Empty descending empty descending stack

The stack starts at a low address and grows toward higher addresses. The stack pointer always points to the next empty location where data will be placed.

◎ Empty ascending empty ascending stack

The stack head is a high address, and the stack grows toward lower addresses. The stack pointer always points to the next empty location where data will be placed.

5. Assembly instructions for operating stacks Stack type Push instructions Pop instructions

Full descending STMFD (STMDB) LDMFD (LDMIA)

Full ascending STMFA (STMIB) LDMFA (LDMDA)

Empty descending STMED (STMDA) LDMED (LDMIB)

Empty ascending STMEA (STMIA) LDMEA (LDMDB)

example:

STMFD r13!, {r0-r5} ; Push onto a Full Descending Stack

LDMFD r13!, {r0-r5} ; Pop from a Full Descending Stack.

Keywords:ARM Reference address:ARM stack study notes

Previous article:ARM v7 Cortex A8 based development platform
Next article:ARM+DSP dual-core processor application strategy

Recommended ReadingLatest update time:2024-11-16 22:25

Embedded Vision System Design Based on ARM9 and Linux
    1 Introduction     Vision systems are widely used in modern industrial production automation systems, mainly in the fields of drug detection and packaging, printing color detection, integrated circuit production, precision electronic product assembly, intelligent robot recognition and navigation, etc. With the pop
[Microcontroller]
Embedded Vision System Design Based on ARM9 and Linux
Design of multiplayer game platform based on ARM and WinSock
Games can not only develop people's intelligence and make people's minds more responsive, but also meet people's spiritual needs (such as adventure, creativity, emotion, etc.). They are very entertaining and interesting and are deeply loved by people. With the vigorous development of the consumer electronics industry,
[Microcontroller]
Design of multiplayer game platform based on ARM and WinSock
Arm revenue hits record high
Earlier, SoftBank Group released the company's revenue data for the first fiscal quarter of 2021 (April to June). In the report, they also disclosed Arm's revenue performance in the first quarter of 2021. Earlier, SoftBank also released the company's financial report performance for fiscal year 2020, which also includ
[Semiconductor design/manufacturing]
Arm revenue hits record high
SiFive launches P870-D, a data center-grade RISC-V core design to compete with Arm Neoverse N2
On August 15, RISC-V IP company SiFive announced the launch of the P870-D CPU design for data center applications yesterday local time. The P870-D builds on SiFive’s P870 high-performance core, released in 2023, and adds a number of new features for data center applications: The P870-D supports the op
[Embedded]
SiFive launches P870-D, a data center-grade RISC-V core design to compete with Arm Neoverse N2
Detailed explanation of ARM processing registers and user mode
37 registers The ARM processor has a total of 37 registers, which are divided into several groups (BANK). These registers include: 31 general-purpose registers: including program counter (PC pointer), all 32-bit registers. 6 status registers: used to identify the working status of the CPU and the running status o
[Microcontroller]
ARM addressing mode
Currently, ARM processors support 9 addressing modes, namely immediate addressing, register addressing, register offset addressing, register indirect addressing, base address index addressing, multiple register addressing, relative addressing, stack addressing and block copy addressing. Immediate addressing: the opera
[Microcontroller]
ARM Litian Electronics LPC2148 12864 without font library displays a Chinese character (serial)
The 12864 small screen in the LPC2148 development board of Litian Electronics does not have a font library, and there is no so-called left and right screens, upper and lower screens, it is a whole screen. (It is produced by Beijing Jicui Electronic Equipment Co., Ltd., for details, see http://download.csdn.net/detai
[Microcontroller]
ARM Litian Electronics LPC2148 12864 without font library displays a Chinese character (serial)
Design of Reconfiguration Controller Based on ARM+FPGA
Abstract: In order to meet the flexibility requirements of reconfigurable systems, this paper introduces the design of a reconfiguration controller with an "ARM processor + FPGA" structure, and proposes a method for the ARM microprocessor to configure the target programmable device in the system through the FPGA tha
[Industrial Control]
Design of Reconfiguration Controller Based on ARM+FPGA
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号