@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ These subroutines assume they are running on the official VVS interpreter
@ which internally uses a twos-complement representation.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Performs a bitwise NOT on the TOS word.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSTSSSN | Mark: 101000 (not)
@ In twos-complement, NOT(X) = (-X)-1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Performs a bitwise AND on the TOS word.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSTSSTN | Mark: 101001 (and)
@ Prepare the stack for computation.
SSSTTTTTTN | PUSH 63 (shift counter)
@ Loop through the bits one at a time.
NSSVSSTSTSSTSSSSSSSSN | Mark: 00101001 00000000
@ Prepare copy of X for the AND
NSTTTSSN | JSR > 1100 (deepdup)
NSTTSTTSSN | JSR > 101100 (rshift)
@ Prepare copy of Y for the AND
NSTTTSSN | JSR > 1100 (deepdup)
NSTTTSSN | JSR > 1100 (deepdup)
NSTTSTTSSN | JSR > 101100 (rshift)
@ Do the AND and store in result.
NSTTSSSSSSN | JSR > 1000000 (lowbitand)
NSTTSTTN | JSR > 1011 (stackrotatereverse)
NSTTSTTSTN | JSR > 101101 (lshift)
NSTTSTSN | JSR > 1010 (stackrotate)
NTSSSTSTSSTSSSSSSSTN | BRZ > 00101001 00000001
@ Decrement the counter and loop again.
NSNSSTSTSSTSSSSSSSSN | JMP > 00101001 00000000
NSSVSSTSTSSTSSSSSSSTN | Mark: 00101001 00000001
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Performs a bitwise OR on the TOS word.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSTSTSN | Mark: 101010 (or)
NSTTSTSSSN | JSR > 101000 (not)
NSTTSTSSSN | JSR > 101000 (not)
NSTTSTSSTN | JSR > 101001 (and)
NSTTSTSSSN | JSR > 101000 (not)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Performs a bitwise XOR on the TOS word.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSTSTTN | Mark: 101011 (xor)
NSTTTSSN | JSR > 1100 (deepdup)
NSTTSTSTSN | JSR > 101010 (or)
NSTTSTTN | JSR > 1011 (stackrotatereverse)
NSTTSTSSTN | JSR > 101001 (and)
NSTTSTSSSN | JSR > 101000 (not)
NSTTSTSSTN | JSR > 101001 (and)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Shifts 'X' right by 'shiftcount' bits with sign extension.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSTTSSN | Mark: 101100 (rshift)
@ Test for loop completion first since it is allowable to shift by zero.
NSSVSSTSTTSSSSSSSSSTN | Mark: 00101100 00000001
NTSSSTSTTSSSSSSSSSSN | BRZ > 00101100 00000000
@ Shift by one bit on each pass.
NSNSSTSTTSSSSSSSSSTN | JMP > 00101100 00000001
NSSVSSTSTTSSSSSSSSSSN | Mark: 00101100 00000000
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Shifts 'X' left by 'shiftcount' bits with zero filling.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSTTSTN | Mark: 101101 (lshift)
@ Test for loop completion first since it is allowable to shift by zero.
NSSVSSTSTTSTSSSSSSSTN | Mark: 00101101 00000001
NTSSSTSTTSTSSSSSSSSN | BRZ > 00101101 00000000
@ Shift by one bit on each pass.
NSNSSTSTTSTSSSSSSSTN | JMP > 00101101 00000001
NSSVSSTSTTSTSSSSSSSSN | Mark: 00101101 00000000
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Performs logical AND on the least-significant bit of 'X' and 'Y'.
@ Returns either 1 or 0, no other values.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSSSSSSN | Mark: 1000000 (lowbitand)