Stack Types and Instructions

The ARM supports four different stack implementations. These are categorised by two axes, namely Ascending versus Descending and Empty versus Full.

An Ascending stack grows upwards. It starts from a low memory address and, as items are pushed onto it, progresses to higher memory addresses.

A Descending stack grows downwards. It starts from a high memory address, and as items are pushed onto it, progresses to lower memory addresses. The previous examples have been of a Descending stack.

In an Empty stack, the stack pointers points to the next free (empty) location on the stack, i.e. the place where the next item to be pushed onto the stack will be stored.

In a Full stack, the stack pointer points to the topmost item in the stack, i.e. the location of the last item to be pushed onto the stack.

As matching these four distinct stack implementations to multiple-register loads and stores has the potential for confusion, the ARM assembly language has specific stack manipulation instructions that indicate through their mnemonic the type of stack involved.

STMEAr13!, {r0-r2}; Push data onto an Empty Ascending Stack
LDMEAr13!, {r0-r2}; Pop data off an Empty Ascending Stack
STMEDr13!, {r0-r2}; Push data onto an Empty Descending Stack
LDMEDr13!, {r0-r2}; Pop data off an Empty Descending Stack
STMFAr13!, {r0-r2}; Push data onto a Full Ascending Stack
LDMFAr13!, {r0-r2}; Pop data off a Full Ascending Stack
STMFDr13!, {r0-r2}; Push data onto a Full Descending Stack
LDMFDr13!, {r0-r2}; Pop data off a Full Descending Stack

These stack manipulation instructions should be used in preference to the standard multiple-register load and store instructions. However, all of the stack manipulation instructions can be mapped to standard forms:

StackStandardType
STMFASTMIBPre-increment store
STMEASTMIAPost-increment store
STMFDSTMDBPre-decrement store
STMEDSTMDAPost-decrement store
LDMEDLDMIBPre-increment load
LDMFDLDMIAPost-increment load
LDMEALDMDBPre-increment load
LDMFALDMDAPre-increment load


References:

http://www-mdp.eng.cam.ac.uk/web/library/enginfo/mdp_micro/lecture5/lecture5-4-2.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值