69

A variable is a logical construct that goes to the intent of an algorithm, whereas a memory location is a physical construct that describes the operation of a computer.  Generally speaking, in order to execute a program there is (compiler generated) mapping between the logical notion of a variable and the storage of the computer. (Even in assembly language ...


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 ...


35

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 ...


27

Intel had 5 pipeline stages in its original Pentium architecture. The number of stages peaked at 31 in the Prescott family, but decreased after that. Today, in the Core series II processors (i3, i5, and i7), there are 14 stages in the processor pipeline. Microarchitecture Pipeline stages P5 (Pentium) 5 P6 (Pentium 3) 10 P6 (Pentium ...


20

Is it safe to say that a variable is the same thing as a memory location? No. Variable and memory location are two abstractions at two different abstraction levels. Variable and pointers are higher level concept at the code/language level, memory location is a lower level concept at the machine level. Once a code had been compiled into an executable, there'...


17

How does understanding physics help people drive a car? They understand phenomena like brake fade, and will compensate for it. They understand center of gravity and how tires grip the road. They understand hydroplaning, and how to avoid it. They know how to best enter and exit a curve. They are far less likely to tailgate. And so on. You can drive a car ...


16

Variables are language constructs. They have a name, reside within a scope, may be referenced by other parts of the code, etc. They are a logical entity. The compiler is free to implement this language construct in any way it pleases, as long as the observable behavior is that prescribed by the language standard. As such, the variable does not even need to ...


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 ...


10

How did heavy software in the early days managed to run on 4MB RAM computer? It wasn't heavy. That's it. There is no magic to it. Your question is based on a false premise. I remember that my mom was using my dad's old IBM PC/AT with 512 KiByte of RAM and a 20 MiByte HDD well into the 1990s for word processing using Volkswriter and then later StarWriter. ...


9

Regarding other modern processors: ARM up to 7: 3 stages (still widely used is simpler devices) ARM 8-9: 5 stages; ARM 11: 8 stages; Cortex A7: 8-10 stages; Cortex A8: 13 stages; Cortex A15: 15-25 stages. From Wikipedia.


8

You might want to step back and see where and why those existing models come from. When a process is created, it is simply given a flat storage area which is simply indexed from 0 to N. Because this storage area (talking about RAM here) is backed by a dedicated hardware and some fancy semiconductors it happens to be pretty fast, but it's not the only one of ...


8

A register-based CPU architecture has one or more general purpose registers (where "general purpose register" excludes special purpose registers, like stack pointer and instruction pointer). An accumulator-based CPU architecture is a register-based CPU architecture that only has one general purpose register (the accumulator). The main advantage/s of "more ...


8

Yes. The DMA controller takes ownership of the bus for the duration of the transfer. That said, I feel obliged to point out that at least on PC-based machines, DMA controllers have been almost entirely obsolete for quite a while now. On a reasonably modern machine, the DMA controller is used only for I/O to/from floppy disks (and only "directly" connected ...


8

This question should be moved to stackoverflow. Maybe someone will do that. Am I correct? Essentially, yes. Each BAR holds the address of a communication area. This address can be set and read by the operating system as part of the larger device configuration. For each BAR (independently), the device stores only some of the bits that the processor ...


7

This really all depends on how you are defining a CPU. If you are talking about the embedded CPUs found in many of the devices you use, then yes, they often contain both the RAM and the processing units that would make up a common computer. If you are talking about a CPU that you would find in a consumer desktop/laptop you would see that the cache you are ...


7

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 ...


7

So basically you access the device controller registers through memory. Not exactly, which is why the diagram in the question doesn't quite depict memory-mapped I/O. Memory-mapped I/O uses the same mechanism as memory to communicate with the processor, but not the system's RAM. The idea behind memory mapping is that a device will be connected to the ...


7

There is no standard which is used by every company: some rely on impersonation; others avoid it at all costs. Impersonation was useful fifteen years ago, where there weren't many convenient tools for screen sharing. Today, not only there are plenty of tools for that, but most users are familiar with at least one of those tools. Moreover, more often than not,...


6

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 ...


5

A flat memory model is generally easier for people to understand, because it is possible to construct a simple mapping between addresses and numbers. This makes it possible to mentally model the address space as a large array and addresses as indices into that array. In a segmented memory model, this mental image of the address space only works within a ...


5

I don't know how much the designers of the ARM architecture took inspiration from the PDP-11. They probably knew the PDP-11 architecture well as it was one of the major CPUs of the 1970s. However, it's more the x86 which is different from the other two. ARM is a RISC architecture: its instructions tend to follow a few model and to do just one thing. Compare ...


5

Short answer: because it is the default approximation of a real number the language in question provides.


5

For integers, the only exponentiation operations that are normally present in hardware are the shifts, << and >> (in C parlance), which multiply by exponential powers of two. For anything else with integers, you run out of bits to represent things far too quickly for it to be useful; by the time you've sorted that problem out, you might as well ...


5

The exponent is unsigned. It cannot be -1. The smallest it can be is 0, which translates to 2^-127. You might ask then, "If so, how is 2^-128 represented in single precision?!". The answer lies in normalization. Usually numbers are normalized (i.e. multiplied by a power of 2) so that the leading bit of their mantissa is 1. That bit can then be omitted,...


5

Microsoft Word for Windows was by today's standard a very small program. Its size is 13.07 MB on installer disks (1.44 MB each), which you can download to check for yourself. Microsoft Word 6.0 for Windows ran first on Windows 3.1 (released April 6, 1992) and looked nothing like Microsoft Word do today: Internet wasn't available, so updates to software ...


5

Let me focus on your actual question - "who's right?" when comparing these two statements: A pointer is a variable whose value is the memory address of another variable A pointer is a memory location whose value is the memory address of another memory location. The answer to this is none. The first one talks of a "memory address of another variable", but ...


5

I certainly wouldn't say that a pointer is a memory location that contains an address. For one, I'm not aware of an architecture where 0x23453 could fit in a single byte. :) Even if you handwave away the byte/word distinction, you still have the problem that every memory location contains an address. Addresses are just numbers, and the contents of memory ...


4

You're mixing things up a bit. You've kind of got the gist of it but not completely. Let's compare General Purpose Microprocessors, Microcontrollers, FPGAs, and ASICs. You've lumped microcontrollers and microprocessors together, when you really shouldn't. General Purpose Microprocessors: These are the desktop and laptop processors, Intel Pentium chips, AMD ...


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