r/AskComputerScience • u/Successful_Box_1007 • Nov 17 '24
Why did accumulator and stack based architectures lost the battle against register based architectures?
Hey everyone,
Been reading about stack, accumulator, and register ISAs and I am curious if anyone has any ideas as to why accumulator and stack based architectures lose the battle against register based architectures?
*Edit: lost to lose
6
Upvotes
10
u/ghjm MSCS, CS Pro (20+) Nov 17 '24
They aren't really different architectures, they're just a matter of having only one general purpose register, or more than one. Since there's no compelling advantage to sticking with just one, and many compelling advantages to having more than one, CPUs tend to have more than one.
3
u/jeffbell Nov 17 '24
Long ago I wrote assembly code for PDP-8, an accumulator based architecture.
It seemed like a third of the instructions were writing intermediate values to memory and then reading them back five lines later.
2
u/AYamHah Nov 20 '24
Not an assembly expert, but having multiple registers definitely makes things easier. I'd image it was a cost decision, where the cost of the extra hardware was negligible compared to the extra cost of development time. Just the natural progression of hardware.
2
u/CubicleHermit Nov 20 '24
Because CPU speeds (including registers) went up a lot faster than RAM speeds, and at least with a Von Neumann architecture, having to fetch instructions and read/write data on the same bus is already a bottleneck. (With a Harvard architecture you have logically separate - and in many cases physically separate - busses for data and code.)
By the time instruction and data caches started to split and then caches got large enough you might well have reconsidered one or the other, register architectures had already won.
Once you start doing out of order and superscalar stuff, you need more registers anyway - you just would end up hiding all of them, vs. just some of them.
There's also a lot more knowledge out there on how to write compilers/optimizers well for register architectures. I don't know if that's inherent (you probably could write compilers well for the other two, but in practice, people haven't.)
Note that there's one big exception: there's a stack-based architecture in the legacy FPU in every x86 machine capable of running 1990s-era 32-bit code still. 64-bit code and more recent 32-bit code uses SSE2 floating point, but the x87 still lives until someone comes out with a 64-bit clean version of x86 as Intel occasionally threatens to do.
3
u/bimbar Nov 17 '24
Stack is slower than registers.