%% file ctm04.txt %% cTM for addition of 2 equal bit binary numbers %% two argument function, argument space separated %% thus input as "101010 101001" for example %% U = UNO, D = DOS, C = CERO %% move to the right until you reach end of input q0 0/0,R q0 q0 1/1,R q0 %% switch state to keep track with empty space in the middle of input %% and continue going to the right on the tape q0 #/#,R q1 q1 1/1,R q1 q1 0/0,R q1 %% reached end of input and commence adding rightmost bit %% to the bit sequence q1 #/#,L q2 q2 1/#,L q3 q2 0/#,L q4 %% bit to be added was 1 q3 0/0,L q3 q3 1/1,L q3 q3 #/#,L q5 q5 D/D,L q5 q5 U/U,L q5 q5 C/C,L q5 q5 1/D,R q7 q5 0/U,R q7 %% bit to be added was 0 q4 0/0,L q4 q4 1/1,L q4 q4 #/#,L q6 q6 D/D,L q6 q6 U/U,L q6 q6 C/C,L q6 q6 1/U,R q7 q6 0/C,R q7 %% return back to the rightmost bit of right bit sequence %% to restart the process q7 U/U,R q7 q7 D/D,R q7 q7 C/C,R q7 q7 #/#,R q8 q8 1/1,R q8 q8 0/0,R q8 q8 #/#,L q9 %% in q9 you see whether the carry calculations can start %% or whether the addition needs to continue q9 #/#,L q9 q9 1/#,L q3 q9 0/#,L q4 q9 D/D,R q10 q9 U/U,R q10 q9 C/C,R q10 q10 #/#,L q11 %% carry calculations are done here q11 C/0,L q11 q11 U/1,L q11 q11 D/0,L q12 q12 U/0,L q12 q12 D/1,L q12 q12 #/1,L q11 q12 C/1,L q11 q11 #/#,R q11