Added example that prints a multi-digit number. Added library functions in support.
[vvhitespace] / stdlib / math.pvvs
diff --git a/stdlib/math.pvvs b/stdlib/math.pvvs
new file mode 100644 (file)
index 0000000..b1a6c0e
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef VVS_STDLIB_MATH
+#define VVS_STDLIB_MATH
+
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@ Description:
+@   This function returns the absolute value of its argument
+@ Call Stack:
+@   signed number  <-- TOS
+@ Return Stack:
+@   abs(signed number)  <-- TOS
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+NSSVTSSSTN              | Mark: 10001 (absolute value)
+SNS                     | DUP
+NTTSSSTSSSTSSSSSSSSN    | BMI > 00010001 00000000
+NSNSSSTSSSTSSSSSSSTN    | JMP > 00010001 00000001
+NSSVSSSTSSSTSSSSSSSSN   | Mark: 00010001 00000000
+SSTTN                   | PUSH -1
+TSSN                    | MULTIPLY
+NSSVSSSTSSSTSSSSSSSTN   | Mark: 00010001 00000001
+NTN                     | RTS
+
+#endif