The meaning of full stack and empty stack in arm and the suffix problem

Publisher:神雕Latest update time:2022-04-14 Source: eefocusKeywords:arm Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

When I first learned ARM instructions, I was always confused about the full stack and the empty stack. According to the literal meaning, that is, the definition in the data structure, an empty stack is a stack with no data, and a full stack is a full stack.

But pay attention to the definition in the book:


Empty stack: When the stack pointer points to the next empty location, it is called an empty stack

Full stack: If the stack pointer always points to the last data pushed into the stack, it is called a full stack.

Therefore, the empty and full here do not indicate the storage status of the stack at all, but only indicate whether the storage unit pointed to by the stack pointer has stored stack data, or whether data can be written directly to the storage unit pointed to by the stack pointer when pushing into the stack. This is the "full stack" and "empty stack". The blogger's understanding is that empty and full only indicate the status of the unit pointed to by the pointer.

Next, let’s talk about what upward growth and downward growth mean, increasing stack and decreasing stack. Oh my, I couldn’t understand the definition at that time.


Increasing stack: growing towards higher addresses

Descending stack: grows towards lower addresses

Let me use a not very vivid picture to illustrate the teacher's classware:

insert image description here

Why do we say "grow upward" and "grow downward"? That's because when drawing a stack diagram, the lower address is drawn at the bottom and the higher address is drawn at the top.


OK, let's talk about the suffix problem related to it:


Index suffix (IA, IB, DA, DB) ---- used for data block transfer, the address base cannot use the SP (R13) register

First explain the meaning of the letters to facilitate memorization

I–Icrement

A—After

B-Before

D – Decrement


IA—post-increment, that is, the base address is increased by 4 after each transfer, pointing to the next word

IB—pre-increment, that is, the base address is increased by 4 before each transfer, pointing to the storage unit where the word transferred this time is located

DA—post-decrement, that is, the address is reduced by 4 after each transfer, pointing to the next word

DB—Pre-decrement, that is, the address is reduced by 4 before each transfer, pointing to the word of this transfer


Stack suffix (FD, FA, ED, EA) ---- The address base must use SP (R13), the stack must use the stack area

F—Full

D—Descending

E – Empty

A—Ascending

insert image description here

Let's discuss the block replication issue:

Which instruction is used depends on whether the data is stored above or below the base register, and whether the address is incremented before or after the first store.

See the following figure for the corresponding command collocation:

insert image description here

Let's take the STMIB STMFA in the first box as an example.

STMIB: Increment before passing (index mode)

SYMFA: Full Incrementing Stack

Keywords:arm Reference address:The meaning of full stack and empty stack in arm and the suffix problem

Previous article:ARM instruction classification (details)
Next article:22 concepts commonly used in ARM development

Latest Microcontroller Articles
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号