Processors who's stack grows up

Jan 04, 2005 41 Replies

Hello,



I am the lead engineer on the Nucleus Plus RTOS. One of my coworkers asked me if I knew any processors that had a stack that grows up. The only one I knew of, for sure, was the Intel i960. We have a fair amount of code in our system that accommodates stacks that grow up. If we can't find a reasonable number of processors who's stack does grow up we will remove that code.



TIA, Adam Messer adam snipped-for-privacy@mentor.com


HP PA-RISC, not commonly used in embedded applications but it does exist. Couldn't point you to a part that is still in production, though.

i960 and PA-RISC are essentially dead architectures; if you don't find a few architectures _with a future_ it probably won't hurt your market share any to remove support for these devices.

that

PIC and 8051 I think. Don't suppose you are interested in these those.

Regards, Richard.

formatting link

On the ARM you can decrement or increment the stack pointer when loading multiple registers - take a look at LDMIA, LDMIB, LDMDA, and LDMDB. I don't know if any standard development environment uses the stack-growing-up convention.

Regards,

-- Georgi

In 32 bit mode ARM can handle the stack both ways.

There is another degreee of freedom: whether the stack pointer points to the last used slot or the first free slot.

In 16 bit Thumb mode of the T variants (e.g. ARM7TDMI), the stack is fixed to grow down.

Tauno Voipio tauno voipio (at) iki fi

"Adam Messer" wrote

8051 family
Nicholas O. Lindan, Cleveland, Ohio Consulting Engineer: Electronics; Informatics; Photonics. Remove spaces etc. to reply: n o lindan at net com dot com psst.. want to buy an f-stop timer? nolindan.com/da/fstop/

Hello,

To all who responded to the question, I say "Thank You"!

Adam

that

I think the PPC is stack-direction-agnostic, though I may be forgetting some corner case where the processor would care. There's no reason you'd define your OS to use an ABI with a stack growing up if it was a problem though. :)

Ben Jackson http://www.ben.com/

I've worked with Nucleus+ for many years, but I don't recall your name. Sorry!

There are plenty.

Unbelievable! An RTOS ***MUST*** be stack-agnostic!!!!

S*it, looks like I'll be pulling nucleus from a current project ...

Unbelievable...

Al.

that

Hi Adam, Maybe You should ask your colleagues doing Microtec compilers... An ARM compiler could be implemented that grew the stack upwards but I have not seen an ARM used this way.

Best Regards, Ulf Samuelsson ulf@a-t-m-e-l.com This is a personal view which may or may not be share by my Employer Atmel Nordic AB

The HP3000.

Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net) Available for consulting/temporary embedded and systems. USE worldnet address!

Al, I do believe you're an asshole.

Why not politely and reasonably argue your position? This guy is asking nicely before he makes a decision, and you could choose to respond in kind, rather than in the manner you did.

It seems to me that by convention, design or happenstance the world has settled on a stack-grows-down philosophy. If you think that's flawed in that processors you're selecting for current or future projects have upward growning stacks (or the option of one, which you are actually planning to use (i.e. is supported by compilers, etc)) then that is useful (as opposed to academic) information that needs to be shared. Good luck with that project.

Regards, Paul.

Al,

The only way to make an OS stack agnostic is to have some sort of conditionals and/or macros every place where the stack must be accessed. One of my coworkers is working on a project to put in an easier porting layer (similar to a HAL or BSP). The code we have for 'stack grows up' makes the affected modules much harder to read. We are trying to weigh the importance of supporting those architectures with the all around readability of the code. Since Nucleus Plus is a source level product, readability is very important. As far as we know no one has ever used the 'stack grows up' conditional.

Adam

Interesting that you can't actually name any...

Why? If no customer ever wants an upward growing stack, then including stack agnosticism is nothing but a source of bugs and increased cost.

For which the Necleus vendor will probably be grateful. Some customers are a net loss.

Wow. Your reaction is what's unbelievable. He hasn't done anything yet. He asks for customer input before making a decision, and you rip him a new one. You must be a real joy to work with.

If you really _use_ Nucleus on a processor with an upwards-growing stack, then speak up. What processor, what compiler?

I agree with the OP. If a feature costs a significant amount of money and is used by 0% of the customer base, get rid of the feature! We all win: fewer bugs, lower costs, better support.

Grant Edwards grante Yow! This PIZZA symbolizes at my COMPLETE EMOTIONAL visi.com RECOVERY!!
[Snipped]
[Snipped]

Regarding the point above. Normally when using a preprocessor to strip out the conditional code. It expands everything. Is there an option or other tool that will only strip out the conditionals ?

Regards Anton Erasmus

PICs (at least the 12-bit and 14-bit cores) don't have a memory-mapped stack, so whether they grow up or down is invisible and hence irrelevant.

Wouter van Ooijen

-- ------------------------------------

formatting link
Webshop for PICs and other electronics
formatting link
Teacher electronics and informatics

The Microchip PIC18 C compiler uses the POSTINC/POSTDEC registers to effect a stack and frame.

Regards,

formatting link

Such as my paper design for a balanced-ternary number system reconfigurable array processor? Which is unlikely to ever exist.

mac the naïf

I'm using a tool called 'preparser' which comes from the isdn4linux community, see:

formatting link

Apparently the sourcecode is not online, but the author says he'll send it upon request.

Rob

Robert Kaiser email: rkaiser AT sysgo DOT com SYSGO AG http://www.elinos.com Klein-Winternheim / Germany http://www.sysgo.com

The MIPS processor doesn't really have a notion of a stack (and I suspect this applies to some other RISC architectures as well). It is up to the compiler to implement a stack and so a compiler writer can choose to let the stack grow up or down. However, I'm not aware of any MIPS compilers that actually let the stack grow up.

Rob

Robert Kaiser email: rkaiser AT sysgo DOT com SYSGO AG http://www.elinos.com Klein-Winternheim / Germany http://www.sysgo.com

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required