3 ms·
Stack machines also tend to have better code density than register or memory machines, and code space is almost always at a huge premium on spacecraft. The hig
by KMag 5y ago
Stack machines also tend to have better code density than register or memory machines, and code space is almost always at a huge premium on spacecraft. The high code density is because most instructions have all arguments implicit (by stack location). The need for stack maintenance instructions like dup and swap means they tend to require more instructions for a given function than a register machine or memory machine, but the per-instruction space savings almost always more than offsets the increased instruction count.
An accumulator machine can be thought of as half way between a register/memory machine and a stack machine, where most instructions have an implicit argument (the accumulator) and an explicit argument. This typically means code density somewhere between a stack machine and a register machine, with very little penalty in terms of instruction count. The main downside of an accumulator machine is the accumulator almost always introduces a dependency between adjacent instructions, making performant superscalar implementations more difficult. IIRC, examples of accumulator machines include V8's current internal bytecode and the old Apple II SWEET16 VM.