<p>Here is the programmed controller for the TTCA string reverse. Because actions (<RT·math>λ</RT·math>) are bound to states rather than transitions, reading and stepping are distinct states, resulting in a strictly serialized execution.</p>
-<RT·code>
+ <RT·code>
# TTCA String Reverse
# input: (σ ∈ Σ)* EOM (starting on the leftmost cell)
# output: SP* EOM (σ ∈ Σ in reverse)* EOR
Q·Done
</RT·code>
+ <img src="TTCA_style_TM_reverse.png" class="rt-diagram" alt="HU reverse machine">
+
+ <RT·code>
+ void TTCA·reverse_string() {
+ // Phase 1: Scan right to EOM and initialize the EOR marker
+ read_g();
+ while(g != EOM){right(); read_g();}
+ right();
+ write_σ(EOR);
+
+ // Phases 2 through 5: The main shuttle cycle
+ while(true){
+
+ // Phase 2: Fetch next unprocessed character and check boundaries
+ left();
+ read_g();
+ while(g == EOM || g == SP){
+ status();
+ if(g == on_leftmost) return;
+ left();
+ read_g();
+ }
+
+ read_d();
+ status();
+
+ // Phase 6: Final character carry and clean halt
+ if(g == on_leftmost){
+ write_σ(SP);
+ right();
+ read_g();
+ while(g != EOR){right(); read_g();}
+ write_d();
+ right();
+ write_σ(EOR);
+ return;
+ }
+
+ // Phase 3 & 4: Mark location, carry opaque data, advance EOR
+ write_σ(SP);
+ right();
+ read_g();
+ while(g != EOR){right(); read_g();}
+ write_d();
+ right();
+ write_σ(EOR);
+
+ // Phase 5: Return left to EOM to begin the next fetch cycle
+ left();
+ read_g();
+ while(g != EOM){left(); read_g();}
+ }
+ }
+ </RT·code>
+
<RT·chapter>The Turing Machine architecture/organization</RT·chapter>
<p>
--- /dev/null
+void TTCA·reverse_string() {
+ // Phase 1: Scan right to EOM and initialize the EOR marker
+ read_g();
+ while(g != EOM){right(); read_g();}
+ right();
+ write_σ(EOR);
+
+ // Phases 2 through 5: The main shuttle cycle
+ while(true){
+
+ // Phase 2: Fetch next unprocessed character and check boundaries
+ left();
+ read_g();
+ while(g == EOM || g == SP){
+ status();
+ if(g == on_leftmost) return;
+ left();
+ read_g();
+ }
+
+ read_d();
+ status();
+
+ // Phase 6: Final character carry and clean halt
+ if(g == on_leftmost){
+ write_σ(SP);
+ right();
+ read_g();
+ while(g != EOR){right(); read_g();}
+ write_d();
+ right();
+ write_σ(EOR);
+ return;
+ }
+
+ // Phase 3 & 4: Mark location, carry opaque data, advance EOR
+ write_σ(SP);
+ right();
+ read_g();
+ while(g != EOR){right(); read_g();}
+ write_d();
+ right();
+ write_σ(EOR);
+
+ // Phase 5: Return left to EOM to begin the next fetch cycle
+ left();
+ read_g();
+ while(g != EOM){left(); read_g();}
+ }
+}