I already showed Turing complete machine with TT parts. It can be seen on the link below.
https://community.turingtumble.com/t/counter-machine-in-3360-lines-tt-vba/705
But it is very large and difficult to understand. In addition, the gear bit chain used for it is impossible to realize.
By creating a special instruction set this time, I made the TC machine executable at TT.
I made it in Excelβs VBA, In order to grasp it, a synthetic image of TT was created.
It includes six sets of gear bit chains as shown below.
D β¦ direction of program counter
PC β¦ program counter
Ptr β¦ pointer shows which RAM (but sequential access!)
and which direction selected
RAM A β¦ left side 4 bit RAM
RAM B β¦ right side 4 bit RAM
Z β¦ reserve bit for zero check
There is a ROM area on the left and right of the PC.
For the program, it is necessary to configure ROM and RAM as initial value.
When parts are set in ROM as follows,
If RAM A is odd, βFβ enters RAM B,
If RAM A is even, RAM B remains β0β
Express this as below for easy viewing. Note that the order of ROM is different from the execution order.
|-|<|
|=|||
|*|=|
|>|-|
In the initial state, βDβ points to the right and PC is 0. That is, the first ball executes β<β on the upper right.
And Ptr points to βA-β.
This, or β>β, is a conditional branch instruction. Details will be described later, but if the referenced RAM A is 0, we will pass through.
That is, PC indicates β|β directly below. Also, Ptr moves 2 as a side effect, and it points to βB-β.
Since TT can not read nondestructively as it is, side effects occur.
The next β|β is NOP. That is, it shifts to β=β below without doing anything.
β=β Is HALT, that is, the program stops there.
Here we consider another case.
If the destination of Ptr is βX+β or if RAM A is not 0, β<β in the upper right inverts D and branches to the left
(In other words, it passes βX-β only when X = 0). As a side effect, subtract 1 from RAM and Ptr moves next.
The PC points to β-β in the upper left. This instruction decrements Ptr by -1.
Ptr is a variable that specifies RAM and its operation and specifies βA -β, βA +β, βB -β, and βB +β in this order.
According to the previous command, Ptr indicates βA +β, so it returns to βA-β by β-β command.
Then execute the above command in the left column.
Since it can not go further up this time, it returns to the β>β at the bottom.
β>β In the lower left shifts to the adjacent column unless RAM A is 0 as well as β<β in the upper right.
Go from β-β in the lower right to β<β in the upper right and repeat < - > - < - > - β¦ until RAM A becomes 0.
After RAM A goes to 0, going to β<β in the upper right will result in NOP-HALT as I just wrote.
On the other hand, when RAM A reaches 0, when reaching β>β in the lower left, go straight there and go to the upper β*β.
At this time, Ptr becomes βB-β due to a side effect.
β" Adds or subtracts RAM according to Ptr. That is, since this time is βB-β, RAM B changes from 0 to βFβ.
For example, if βA+β, 1 is added to RAM A. After that, shift Ptr by +1. This is actually the same as the side effect of β>β.
By skillfully combining "β and β-β, it is possible to arbitrarily change the values of Ptr and RAM.
After β*β execution, it reaches β=β above and stops.
Here, write β>β, β<β in further detail.
The first blue ball passes through most of the blocks and reverses only the last βZβ.
Furthermore, by falling to the right side, the next ball becomes red.
The red ball reverses βDβ, ignores the PC and always performs β*β operation.
Ptr points to βX+β. Or, if the RAM is not 0, the next ball is blue.
That is, the PC was reversed.
On the other hand, when the condition of βX-β and 0 is caught, the next ball is a red ball.
Since the red ball reverses βDβ, it means that no branching will occur as a result.
Also, the next ball inevitably becomes blue.
In theory, RAM and ROM can be increased any number.
It does not matter the physical limit of the Gear bit.
The attached Excel file also includes examples of counting and addition.
Thank you for reading.
TT_CPU.xlsm (62.5 KB)