diff options
-rw-r--r-- | algorithm.txt | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/algorithm.txt b/algorithm.txt index 82e0d69..109a7b1 100644 --- a/algorithm.txt +++ b/algorithm.txt @@ -12,6 +12,63 @@ Tape - Each cell: [ 0 | head | tt1 | tt2 | sym ] +Read input +========== + +Write 1, move right a rule width +Go to tr1 +Write 1 +While nonzero: + Read into qfrom + + Read into sread + Copy to sread+1 (scratch sread+2) + Write 1 to sread+2 + Subtract 32 from sread+1 and go to sread+1 + While nonzero: + Subtract 1 from sread+2 + Zero sread+1 and go to sread+1 + Go to sread+2 + While nonzero: + Zero sread + Zero sread+2 and go to sread+2 + Go to sread + + Read into qto + + Read into swrite + Copy to swrite+1 (scratch swrite+2) + Write 1 to swrite+2 + Subtract 32 from swrite+1 and go to swrite+1 + While nonzero: + Subtract 1 from swrite+2 + Zero swrite+1 and go to swrite+1 + Go to swrite+2 + While nonzero: + Zero swrite + Zero swrite+2 and go to swrite+2 + Go to swrite + + Read into dir + Subtract '=' (61) from dir + Copy qfrom to tr4 (using tr3 as scratch) + Go to tr4 + While nonzero: + Add 1 + While nonzero: + Write 1 to rightrule.tr1 + Zero tr4 + Zero tr4 + + Go to rightrule.tr1, which is 1 precisely if we didn't have EOF + +Now at a zero tr1 that is really the qcurrent of Mmarker +Write 'S' (83), and go to Mmarker.0 +Write 1 +Set rightcell.head to 1 +Go back to Mmarker.0 + + Execution step ============== |