Back to Basics – Laying the Foundation

Pages: 1 2 3 4

Finding the Prettiest Model

An ISA must also specify the operation model it adheres to. This is mostly for the benefit of the assembly programmer and the compiler. There are roughly speaking, five different models for where operands can be located:

  1. Stack Based
  2. Accumulator
  3. Memory-memory
  4. Register-memory
  5. Load-store or register-register

In stack based architectures, one of the operands always is on the top of the stack, which is indicated by a pointer, innovatively named the top of stack pointer. This can point anywhere; however it is common to have a small and fast data location to store the top of stack pointer to increase performance. This pointer can be directed anywhere in the memory. The other operand typically comes from anywhere else in the stack typically, although some models only allow the operands to come from the top two positions in the stack.

An accumulator is to some degree a simplified version of a stack. In any operation, one of the operands is always the accumulator. So when you issue an instruction (Load, 3), it automatically loads 3 into the accumulator, had we used (Store, 3) the value in the accumulator would be stored to memory location 3. One of the nicer aspects of the accumulator is that it is really good for sequential instructions, as the output of the nth operation is automatically the input for the (n+1)th operation. This can lead to much denser code, since one of the operands is always the accumulator, although it does give the programmer less freedom.

Another scenario is where both operands can come from anywhere in the memory. This has the advantage of giving the compiler and the assembly programmer much more flexibility and relieving the need for illustrative pictures. However, memory-memory architectures are no longer really used at all, because of the performance penalty in comparison to other architectures.

Unlike the previous models, register-memory is still in very wide usage. A register is a small and temporary, but very fast area for storage within a processor. Values that will be shortly consumed by execution units are typically stored in registers, as well as frequently used constants, such as 0. In a register-memory system, at least one of the operands comes from the registers and the output also goes to a register, with the other input coming from either memory or the registers.

In load-store architectures, instructions are restricted to only using registers as source or destination operands; except for the load instruction, which write data in memory to a register and a store instruction, which writes the value in a register to a memory location. This allows actual calculations (as opposed to data movements) to be very quick, since registers are much faster than memory

As it turns out, the best model, in terms of performance, is the load-store architecture, and almost all new architectures since the 80’s have been load-store machines. This transition was partially caused by the shift from assembly programming to compilers and programming languages. The earlier accumulators and stack based models used shorter instructions, and hence, programs usually had smaller memory footprints and were easier to conceptualize; hence they were much more popular with assembly programmers. Only with the advent of compiled high level languages did the trade-off of increased performance for more restrictions in assembly code truly make sense.

Pages: « Prev   1 2 3 4   Next »

Discuss (18 comments)