aboutsummaryrefslogtreecommitdiff
path: root/samples/clamp.orgaasm
diff options
context:
space:
mode:
Diffstat (limited to 'samples/clamp.orgaasm')
-rw-r--r--samples/clamp.orgaasm26
1 files changed, 26 insertions, 0 deletions
diff --git a/samples/clamp.orgaasm b/samples/clamp.orgaasm
new file mode 100644
index 0000000..ecd2824
--- /dev/null
+++ b/samples/clamp.orgaasm
@@ -0,0 +1,26 @@
+ #000f #00f0 #0042 DBG
+ /clamp DBG POP
+ #000f #00f0 #0f00 DBG
+ /clamp DBG POP
+ #000f #00f0 #0001 DBG
+ /clamp DBG POP
+ RET
+
+@clamp ( min max a -- b )
+ /min /max RET
+
+@min ( a b -- a < b ? a : b )
+ OVR OVR LTH
+ JNZ ,min/morethan
+ SWP
+@min/morethan
+ POP
+ RET
+
+@max ( a b -- a > b ? a : b )
+ OVR OVR GTH
+ JNZ ,max/lessthan
+ SWP
+@max/lessthan
+ POP
+ RET