Counter machines, and program counters (aka instruction pointers) and instruction registers; and Turing-equivalence of counter machines

Counter machines

Introduction

System has set of registers rather than a tape.

Head of machine points to specific instruction, head position can be changed. Head moves to next line after running (unless a jump)

Instructions include:

+ Increment given register

+ Decrement given register

+ Clear given register

+ Copy contents of one register to another

+ Jump to instruction if a given register is zero

+ If two registers have same value then jump to instruction

Program counters (aka instruction pointers)

Introduction

program counter: memory address of next instruction to be executed

program counter has address of next instruction. to load puts address in address bus. data bus sends instruction to address bus. data bus sends instruction to CPU

more complex if instruction longer thna 1 byte

The actual instruction is taken from the location stored in the program counter, and stored in the instruction register

Turing-equivalence of counter machines

Simulating a Turing machine with a counter machine

We know from earlier that a \(2\) stack machine is equivalent to Turing machine.

A stack can be simulated with \(2\) counters, therefore a \(4\) counter machine can simulate a Turing machine.

\(4\) counters can be simulated by \(2\) counters, and therefore a machine with just \(2\) counters is Turing equivalent.

Simulating a counter machine with a Turing machine