tags:

views:

48

answers:

3

can I use more than one stack in microprocessor? and if I can,How can I progamming those?

A: 

If your microprocesser has more than one hardware stack, then yes, you can. You would have to write assembler though, since no c/c++ implementation makes use of multiple stacks.

It would be easier to help if you could say exactly what architecture you're talking about.

Autopulated
+1  A: 

Sure you can. Several CPU architectures have multiple stack pointers - even lowly 8-bit processors, such as the M6809. And even if the concept is not implemented in the CPU hardware, you can easily create multiple stacks in software. A stack pointer is basically simply an index register, so you could (for example) use the IX and IY registers of the Z80 to implement multiple stacks.

anon
But only one is generally available to use code, and certainly only one is used by compiled code. The other is for interrupts.
Autopulated
@Auto Not in the 6809, which I have extensive programming experience of. Both are available from user code.
anon
A: 

As for the how of it. Generally there is a special register or memory location that is used to point to the stack. Using another stack is just as simple as setting this value. This is all processor and architecture dependent so it depends on the one you are using.

Ukko