Added isnegative and lowbitand subroutines to VVS stdlib.
authorAaron Taylor <ataylor@subgeniuskitty.com>
Fri, 26 Jul 2019 07:19:13 +0000 (00:19 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Fri, 26 Jul 2019 07:19:13 +0000 (00:19 -0700)
stdlib/README.md
stdlib/logic.pvvs
stdlib/math.pvvs

index 099a70e..b41e251 100644 (file)
@@ -64,8 +64,8 @@ header comment for each function to learn the call and return stack.
          111000 ----- dump heap                     (debug.pvvs)
          111001 ----- dump stack                    (debug.pvvs)
         1xxxxxx - reserved for less common entry points
          111000 ----- dump heap                     (debug.pvvs)
          111001 ----- dump stack                    (debug.pvvs)
         1xxxxxx - reserved for less common entry points
-        1000000 ----- <empty>
-        1000001 ----- <empty>
+        1000000 ----- lowbitand                     (logic.pvvs)
+        1000001 ----- isnegative                    (math.pvvs)
         1000010 ----- print sign of number          (stdio.pvvs)
         1000011 ----- print magnitude of number     (stdio.pvvs)
         1000100 ----- print string from stack       (stdio.pvvs)
         1000010 ----- print sign of number          (stdio.pvvs)
         1000011 ----- print magnitude of number     (stdio.pvvs)
         1000100 ----- print string from stack       (stdio.pvvs)
index eccc68b..b5c414d 100644 (file)
@@ -90,4 +90,27 @@ NSSVSSTSTTSTSSSSSSSSN   | Mark: 00101101 00000000
 SNN                     | DROP
 NTN                     | RTS
 
 SNN                     | DROP
 NTN                     | RTS
 
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@ Name:
+@   lowbitand (1000000)
+@ Description:
+@   Performs logical AND on the least-significant bit of 'X' and 'Y'.
+@   Returns either 1 or 0, no other values.
+@ Call Stack:
+@   X
+@   Y
+@ Return Stack:
+@   lsb(X) AND lsb(Y)
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+NSSVTSSSSSSN            | Mark: 1000000 (lowbitand)
+SSSTSN                  | PUSH 2
+TSTT                    | MODULO
+SNT                     | SWAP
+SSSTSN                  | PUSH 2
+TSTT                    | MODULO
+TSSS                    | ADD
+SSSTSN                  | PUSH 2
+TSTS                    | DIVIDE
+NTN                     | RTS
+
 #endif
 #endif
index d618d83..7bd73e5 100644 (file)
@@ -55,4 +55,22 @@ TSSN                    | MULTIPLY
 NSSVSSSTSSSTSSSSSSSTN   | Mark: 00010001 00000001
 NTN                     | RTS
 
 NSSVSSSTSSSTSSSSSSSTN   | Mark: 00010001 00000001
 NTN                     | RTS
 
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@ Name:
+@   isnegative (1000001)
+@ Description:
+@   Returns 1 if 'number' is negative, 0 if positive.
+@ Call Stack:
+@   number  <-- TOS
+@ Return Stack:
+@   1 or 0  <-- TOS
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+NSSVTSSSSSTN            | Mark: 1000001 (isnegative)
+NTTSTSSSSSTSSSSSSSSN    | BMI > 01000001 00000000
+SSSSN                   | PUSH 0
+NTN                     | RTS
+NSSVSTSSSSSTSSSSSSSSN   | Mark: 01000001 00000000
+SSSTN                   | PUSH 1
+NTN                     | RTS
+
 #endif
 #endif