From 1f6ed601a14ef9bb6651a9ff0000155929473d0c Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 2 May 2024 16:15:17 +0100 Subject: e --- test.r1 | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 test.r1 (limited to 'test.r1') diff --git a/test.r1 b/test.r1 new file mode 100644 index 0000000..8a51d81 --- /dev/null +++ b/test.r1 @@ -0,0 +1,67 @@ +: sqrt +i mark2 dup +i loc0 sto +c /2 +i loc1 sto +% loop +i loc0 lod +i loc1 lod +c newton +i dup loc1 +c replace! +c thresh +c close? +b loop +i loc1 lod +i ret2 + +: newton +c tuck +c square +i add div +c /2 +i ret0 + +: square +i dup mul +i ret0 +: tuck +i dup nrt +i ret0 + +: replace! +i dup lod +i nrt sto +i ret0 + +: close? +i nrt +c absdiff +i swp sle +i ret0 + +: /2 +i lit2 div +i ret0 + +: thresh +i lit4 ret0 + +: absdiff +i sub + +: abs +i lit0 slt +b f1 +i neg +% f1 +i ret0 + + +: hypot +c square +i swp +c square +i add +c sqrt +i ret0 -- cgit v1.2.3