Instruction Fetch & Execute

There is a lot of computer history leftover in the languages we use today. For example, C's and now Javascripts includes pre and post increment operators, ++. These are a throwback to overlapping memory and arithmetic operations in the earliest computers. This is most obvious in the tradition of incrementing a program counter before executing an instruction.

The run flag would enable fetching the next instruction and incrementing the program counter in a single cycle. This is an optimization made possible because the arithmetic-logic unit (ALU) would be unused otherwise while waiting for the memory cycle to complete.

while(run) { ir = memory[pc++]; switch (ir) { ...

Index registers were a later addition to computer architectures that preserved this efficiency by adding an increment on indirect reference bit to the fetch instruction.

This technique was especially useful on the PDP-8 where the index registers were really just core memory locations treated specially. Core reads were destructive so each had to be followed by a write. Auto-increment would just run the memory contents through the ALU before rewriting it.

I recently revised code I was writing to use these conventions and terminology to some benefit. github