Removed `isnegative` subroutine from stdlib.
[vvhitespace] / stdlib / math.pvvs
index b1a6c0e..d618d83 100644 (file)
@@ -2,8 +2,44 @@
 #define VVS_STDLIB_MATH
 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 #define VVS_STDLIB_MATH
 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@ Name:
+@   random (10000)
 @ Description:
 @ Description:
-@   This function returns the absolute value of its argument
+@   Returns a kinda-random number.
+@   Before using for the first time, seed heap[0] with a value.
+@ Call Stack:
+@   empty
+@ Return Stack:
+@   random number  <-- TOS
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+NSSVTSSSSN              | Mark: 10000 (random)
+
+@ Generate the next seed value
+SSSSN                   | PUSH 0 (ptr)
+TTT                     | LOAD
+SSSTSSSSSTTTSSSTTSSTSSTTTSSTTSTTSTN | PUSH 1103515245
+TSSN                    | MULTIPLY
+SSSTTSSSSSSTTTSSTN      | PUSH 12345
+TSSS                    | ADD
+
+@ Store the next seed value but keep a copy on the stack.
+SNS                     | DUP
+SSSSN                   | PUSH 0 (ptr)
+SNT                     | SWAP
+TTS                     | STORE
+
+@ Calculate the random number and return.
+SSSTSSSSSSSSSSSSSSSSN   | PUSH 65536
+TSTS                    | DIVIDE
+SSSTSSSSSSSSSSSSSSSN    | PUSH 32768
+TSTT                    | MODULO
+NTN                     | RTS
+
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@ Name:
+@   abs (10001)
+@ Description:
+@   Returns the absolute value of its argument
 @ Call Stack:
 @   signed number  <-- TOS
 @ Return Stack:
 @ Call Stack:
 @   signed number  <-- TOS
 @ Return Stack: