Talk:Stack machine

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Examples[edit]

It would be nice to have some code examples. --Crazy2k 15:16, 24 August 2009 (UTC) —Preceding unsigned comment added by 186.136.149.162 (talk) [reply]

So what's a stack machine?[edit]

As far as I can gather, a stack machine is essentially a computer without general-purpose storage registers by using stacks in their place? If so, the article should put this up front as it would be the most clear explanation. If not...well, then I don't get it. --Apantomimehorse 09:58, 18 September 2006 (UTC)[reply]

Could you clarify what you think is unclear? I think the intro already states what you just wrote in the very first sentences. — Tobias Bergemann 12:42, 18 September 2006 (UTC)[reply]
There is now a section explaining that 1-stack machines are less powerful than even deterministic pushdown automata, so they can't be the same as pushdown automata. But a formal definition, from which we could actually see this, is still lacking. Rp (talk) 15:25, 9 July 2008 (UTC)[reply]
How can that be sense they would not have any problem implementing any stack-automata. And why would they be compared to pushdown automata. A prime example of a stack machine is the Burroughs ALGOL machines.
Steamerandy (talk) 21:00, 28 November 2018 (UTC)[reply]
Now covered in 2nd sentence of section on practical expression-stack machines. DBSand (talk) 05:37, 1 April 2011 (UTC)DBSand[reply]

Please support the contention that "two-stack" machines are more prelevant.[edit]

I just upgraded the skecpticism tag from "citation needed" to "dubious."

One-stack machines include x86 (8086 through Core 2), PowerPC, M68000, SPARC, and MIPS architectures. This covers "most" of todays machines easily. so where are the "two-stack" machines? Yes, these are not "pure" stack machines, as they have registers in addition to stacks, but they still fundamentally use stacks.

Note that the ability to switch between multiple stacks quickly is a hallmark of a "one-stack" architecture. do not confuse this with a two-stack architecture.

From the article:

"A machine using processor registers for operands can easily simulate a stack machine."

From this text in the article it's clear to me that neither of the above mentioned processors are defined as stack machines, even though they implement a stack. If this is false, then we need to change the definition of what a stack machine is. Pipatron 09:46, 30 November 2006 (UTC)[reply]
Why do you think those machines are "one-stack" machines? Forth implementations on the 8086 typically use the "SP" and "BP" registers as the 2 stack pointers[1]. The M68000 can directly support up to 8 stacks, such that standard stack operations can be done in a single instruction. Not just "push" and "pop", but also addition/subtraction/multiply/logical ops, in a single instruction.
You may be surprised to learn that the above list does *not*, in fact, cover the majority of CPUs. "about 55% of all CPUs sold in the world are 8-bit" -- see microprocessor.
--68.0.120.35 06:05, 9 February 2007 (UTC)[reply]
Nearly all current machines and languages use call stacks, so that property is no longer useful in distinguishing the rare-bird stack machines from the near-universal register machines. I've change the definitions to treat these separately. DBSand (talk) 05:30, 1 April 2011 (UTC)DBSand[reply]
A stack machine is a machine that accually "thinks" of its -operands- in terms of stacks at the microcode level, logic level, or basicly a level below the code that it accaully executes, not at the level of the program running on it. The 8086 does not directly support an operand stack, just a local variable/return (combined) stack. "Stack machines" and "machines that can implement a stack" are two very different things. Further, I find it strange that you reference PowerPC, SPARC and MIPS, because although their variable/return (combined) stack is almost universally used because of their respective UNIX System V ABIs, nothing in the processors themselves mandates the stack structure that they use. Look at the System V ABIs to verify this yourself. Further, althouth the 8086 and M68000 have push, pop, call, ret, and iret instructions that increment/decrement the stack pointer and store new/retreive existing data stored at it, neither have instructions to accually preform operations on the retreved data as it is being retreived. In other words, you must preform a "POP AX" then an "ADD AX, ...", and further a "PUSH AX" before you get the same result that a stack machine gives. Thus, it is not a good practice to program this way on those architechtures. The 8087 (The floating point math coprocessor) is a stack machine, though.
Added x87 as an example of hybrids between stack and register machines. DBSand (talk) 05:30, 1 April 2011 (UTC)DBSand[reply]
Most stack machines are, infact two-stack machines. One for operands and one for loop counters. It also happens that the loop counter stack is used for return values in most stack machines, because its a convienant place for them. Look at Patriot Scientific, or Forth Machines, or varius Postscript processors found in many printers... They are all 2 stack (or more in the case of Postscript) machines.
I am pretty sure you are right -- most stack machines are two-stack machines. However, one of the little games we play on Wikipedia is to find a reference for facts, even when we are pretty sure they are true. Could you find a reference for us? --68.0.124.33 (talk) 05:05, 2 June 2008 (UTC)[reply]

merge with pushdown automaton[edit]

I have tagged this article to merge with pushdown automaton. The two are formally the same. I am creating a similar article called queue machine which would list both theoretical and practical concerns, as I believe that is the main difference between the two articles. —Preceding unsigned comment added by SamuelRiv (talkcontribs) 03:30, 6 November 2007 (UTC)[reply]

The present text of this article makes it clear that the two are not the same, so merging is a bad idea. Rp (talk) 15:26, 9 July 2008 (UTC)[reply]
I agree with Rp. This article discusses the stack machine concept (computational model) in computer science whereas the pushdown automation article discusses the pushdown finite automation concept, which may use a stack (which is just an array with LIFO-based access). The two articles discuss completely different concepts. No merge should be done. -- Burningmace 00:03, 23 December 2008 (UTC) —Preceding unsigned comment added by Burningmace (talkcontribs)
The merge is not really a good idea. The term "stack machine" was specifically used to describe a particular sort of widely implemented CPU architecture. A "pushdown automaton" is a formal concept, that does not carry the same connotations. I will remove the tag. --pbannister (talk) 11:55, 12 February 2009 (UTC)[reply]

Interrupt latency[edit]

I have gotten the impression that many, if not all, stack processors tend to have short interrupt latencies. The Intersil RTX2010 e.g. has a an interrupt latency of only four processor cycles. Can the same be said for other stack processor architectures? Johan G (talk) 16:32, 7 March 2009 (UTC)[reply]

Added RTX2010 as example of fast interrupt response due to minimal processor state. DBSand (talk) 05:35, 1 April 2011 (UTC)DBSand[reply]

(CONSIDER REVISION, NOT QUITE RIGHT)[edit]

Someone added this phrase to the section heading in the article this morning. My understanding is that that sort of thing doesn't belong in the article, so I've removed it. However, the editor is correct: that example is wrong; it confuses pushdown automata with a stack machine. A 'stack machine' is a general purpose computer that has a stack AND random-access memory, as discussed in "merge with pushdown automaton".

In fact, it may be better if that section was removed, or replaced with one explaining why a "stack machine" has nothing to do with pushdown automaton. 152.23.116.140 (talk) 15:34, 10 November 2009 (UTC)[reply]

Should we mention the SECD machine here?[edit]

The SECD Stack Environment Code Dump, machine is a device used to implement the lispkit language, a lisp dialect similar to scheme used by Peter Henderson in his book Functional Programming, prentice hall, 1980. There is an article in wikipedia about SECD, It should remain as a separate entry. I suggest just to mention it. Maybe just the first paragraph in this comment is enough. —Preceding unsigned comment added by 189.140.221.202 (talk) 07:38, 5 December 2010 (UTC)[reply]

I added it to "see also" --Mathnerd314159 (talk) 16:44, 30 June 2021 (UTC)[reply]

Separate articles for automata theory stack machines and practical stack machines[edit]

This article now covers three different topics with no overlap.

The sections on automata theory stack machines and practical stack machines should become separate stand-alone articles, with a disambiguation page.

The section on computers using stack frames should probably have its details moved into the existing stack frame article, and leave only a note here within the practical stack machine article, explaining that nearly all machines use stack frames, and most of them are considered register machines, not stack machines.

The existing article on register machines only covers automata theory, with nothing about practical real machines. It would be good to create a similar article about practical register machines.

DBSand (talk) 05:01, 1 April 2011 (UTC)DBSand[reply]


The subject of automata theory stack machines and the languages they can parse is covered in existing articles pushdown automaton and deterministic pushdown automaton; the example here should be merged into one of those articles. DBSand (talk) 15:18, 14 June 2012 (UTC)[reply]
Done DBSand (talk) 22:38, 16 June 2012 (UTC)[reply]

Density of content, assumption reader will understand terms[edit]

This article, in many parts, reads like it is a slab of text taken out of a compiler or computer organization textbook. The article goes too deep (tons of irrelevant detail). There is an assumption the reader will understand many technical terms, with no attempt at definition or linkage to other wikipedia articles. The entire section on call stacks should jsut be a link to the call stack wikipedia article (which is very well written). This article, however, is just an extremely poorly written article, overall. — Preceding unsigned comment added by 131.170.90.2 (talk) 07:06, 10 September 2011 (UTC)[reply]

Comparison of stack and register machines[edit]

Hello. I was just reading at the following :

Stack machines have much smaller instructions than the other styles of machines. But operand loads are separate and so stack code requires roughly twice as many instructions as the equivalent code for register machines. The total code size (in bytes) is still less for stack machines.

This is vague and unsourced. What kind of stack machine and register machines are compared ? A stack machine can be :

  • With one stack (data and return addresses is explicit) or two stacks (separate data and return stacks)
  • With or without an accumulator (usually without)
  • With or without flags (such as carry flag, usually without)

A register machine can be :

  • With how many registers (8, 16, 32, ...)
  • Has "fake" registers such as Program Counter, or a Zero register
  • Instructions with 3, 2 or 1 explicit registers
  • Which addressing modes are available (to simulate a stack frame for instance) ?

And in both cases : Are instructions encoded with practical memory alignment in mind (i.e. 1 byte / multiple bytes per instructions), or designed for maximum density (common instructions uses less bits and rare instructions use more bits) ?

All those factors impact greatly on code density, and claiming which one is generally the winner is not something that can be easily done. If such a study has already been made, then a serious source should be provided that, The total code size is still less for stack machines.

Otherwise this paragraph is void and should be removed, but as usual, people will repeat it around and say It must be true because Wikipedia says so128.179.157.83 (talk) 09:21, 16 April 2015 (UTC)[reply]

History of the Stack Machine[edit]

It would be good to include a little on the history of the stack machine. When was the stack mechanism explicitly supported by CPU instruction sets. Who came up with this idea. Some credit Friedrich L. Bauer with this invention (together with Klaus Samelson he apparently patented it in 1957); also see Jürgen Schmidhuber's page on Friedrich L. Bauer.

Wstomv (talk) 12:23, 21 July 2018 (UTC)[reply]

Stack Machine Lists[edit]

The lists near the bottom of the article (Commercial Stack Machines and Virtual Stack Machines) should include a date and/or be put in approximate historical order. 50.206.176.154 (talk) 21:44, 12 April 2021 (UTC)[reply]

Aren't GPUs Stack Machines?[edit]

It is my understanding that some of the subordinate processors (that do not run their own OS like a GPU but only execute instructions pushed into them from a master processor) are essentially stack machines. They have a data stack that can be accessed by the master, which can push and pop, and that can be accessed by the subordinate's ALU. A separate instruction queue is filled by the master at the tail and executed by the subordinate from the head.

I recommend that such a subordinate processor be included in the description of the different kinds of stack machines. 50.206.176.154 (talk) 03:32, 14 January 2022 (UTC)[reply]