commit c67c16531ff7acf7b2f669970691ff1fc09f7787 parent 85b6228809bb1895bb2b376ae4ad1495c43c3f44 Author: Henry Wilson <m3henry@googlemail.com> Date: Tue, 1 Aug 2017 15:03:49 +0100 added DO ... +LOOP Diffstat:
M | compiler.s | | | 43 | +++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 43 insertions(+), 0 deletions(-)
diff --git a/compiler.s b/compiler.s @@ -52,6 +52,8 @@ verb forth compend "\x3B" immediate # ; set LAST endword +# Indefinite Loops + verb forth BEGIN "BEGIN" immediate get HERE endword @@ -84,3 +86,44 @@ verb forth REPEAT "REPEAT" immediate do SWAP do store endword + +# Finite Loops + +verb forth DO "DO" immediate + get HERE + compile pushret # Loop Counter + compile pushret # # Loop End + endword # # + +verb forth LOOP "LOOP" immediate + compile popret # # + compile popret # + compile inc + compile dup2 + compile nequal + compile dobranch + compile + compile drop2 + endword + +verb forth plusloop "+LOOP" immediate + compile popret # # + compile SWAP # + compile popret # + compile SWAP + compile pushret # Increment + compile dup2 # + compile lequal # + compile popret # + compile SWAP + compile pushret # Less Before? + compile plus # + compile dup2 # + compile greater # + compile popret # + compile XOR + compile dobranch + compile + compile drop2 + endword +