Hot answers tagged

49

A (somewhat) popular alternative to a call stack are continuations. The Parrot VM is continuation-based, for example. It is completely stackless: data is kept in registers (like Dalvik or the LuaVM, Parrot is register-based), and control-flow is represented with continuations (unlike Dalvik or the LuaVM, which have a call stack). Another popular data ...


36

In the olden days, processors didn't have stack instructions, and programming languages didn't support recursion. Over time, more and more languages choose to support recursion, and hardware followed suite with stack frame allocation capabilities. This support has varied greatly over the years with different processors. Some processors adopted stack frame ...


14

TL;DR Call stack as a function call mechanism: Is typically simulated by hardware but is not fundamental to the construction of hardware Is fundamental to imperative programming Is not fundamental to functional programming Stack as an abstraction of "last-in, first-out" (LIFO) is fundamental to computer science, algorithms, and even some non-technical ...


11

No, not necessarily. Read Appel's old paper Garbage Collection can be faster than Stack Allocation. It uses continuation passing style and shows a stackless implementation. Notice also that old computer architectures (e.g. IBM/360) did not have any hardware stack register. But the OS and compiler reserved a register for the stack pointer by convention (...


10

You've got some good answers so far; let me give you an impractical but highly educational example of how you could design a language without the notion of stacks or "control flow" at all. Here's a program that determines factorials: function f(i) => if i == 0 then 1 else i * f(i - 1) let x = f(3) We put this program in a string, and we evaluate the ...


3

The reason why the hardware isn't bit addressable is the cost and complexity to address to that level of granularity isn't justified. You need more wires the more accurately you address. A lot of computers aren't really byte addressable either. They tend to move memory around in bigger chunks, 64 bytes is common. Processors do allow you to read and write ...


3

In most cases, yes, cycle time for each stage is fixed. There are some exceptions, depending on processor. But the description you give is vastly over-simplified. Modern processors are organised in pipelines, so that one stage of execution of one instruction can occur at the same time as others. While some processors use a 6-stage pipeline like you describe,...


3

Since the publication by Parnas in 1972 of On the criteria to be used in decomposing systems into modules it has been reasonably accepted that information hiding in software is a good thing. This follows on a long debate throughout the '60s on structural decomposition and modular programming. Modularity A necessary result of black-box relationships between ...


2

All the old mainframes (IBM System/360) had no notion of a stack at all. On the 260, for example, parameters were constructed in a fixed location in memory and when a subroutine was called, it was called with R1 pointing to the parameter block and R14 containing the return address. The called routine, if it wanted to call another subroutine, would have to ...


2

First and foremost when you say "typically" I would have to disagree with that. Yes, in text books all derived from each other they talk about those states in the pipeline. But that was a long time ago now and pipelines have changed in size and shape every generation (every year or two). But that is not relevant to your question. The answer is "it ...


2

how do these purely theoretical models of computation relate to real-world computer architecture? They don't. Both λ-calculus and Turing Machines were designed to model the way a human computes. They weren't designed to model computing machines. This is most obvious in the Turing Machine, which was heavily modeled after the way a "computer" (which ...


1

Here are some thoughts: You can address 8 times less memory with same size of addresses do you just want to address bit wise and still operate on 8,16,.. bits at once just at bit addressable positions? do you wish assembly commands just working on single bits? registers in the CPU and also the data buses between the components of the hardware have fixed ...


1

Let's ignore that your model is not how a typical modern CPU works; it was quite reasonable a few years ago. On a modern CPU, the clock rate is not absolutely fixed, but it definitely doesn't change from instruction to instruction. The CPU will measure its temperature, or will be told by the operating system that it needs to use as little power as possible,...


1

How many bits of address is required (for the program counter for example) in a byte-addressed computer with 512 Mbyte RAM? There is no answer. For modern systems software uses virtual memory, and virtual memory has nothing to do with physical memory. For example, you might have 512 MiB of RAM, 1.5 GiB of swap space, and 2 GiB of memory mapped files. ...


1

There is still no consensus: The majority of larger computer systems (server/desktop/laptop) currently use little-endian architectures The majority of smaller computers (tablets/phones) use an endianness-independent processor architecture, but run operating systems that use little-endian order So at the hardware level, LE is far more common. But: Most ...


1

No, nobody has won. We as a species we have failed to standardize the order in which we store our bytes, along with the direction we write and the side of the street we drive on. As a consequence, anyone who wants to transfer data between two different systems over a network or in a file, has only about a 50% chance of the reasonable initial version of ...



Only top voted, non community-wiki answers of a minimum length are eligible