您的位置:首页 > 其它

Stack Types and Instructions

2015-05-28 07:20 288 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ARM stack