From 7bc67b0f725afa15bab8cef1e1bea5f2fb86b543 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 15 Apr 2018 17:16:46 +0200 Subject: Add input reading algorithm --- algorithm.txt | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) 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 ============== -- cgit v1.2.3-70-g09d2