SM3B: A Small 3-Bit Instruction Set

2^3 = 8 instructions

Symbol Description
0 Resets X if previous instruction not 0 or 1. Leftshifts X.
1 Resets X if previous instruction not 0 or 1. Leftshifts X and adds 1.
+ Adds X to C (accumulator) and copies the result into X
- Subtracts X from C (accumulator) and copies the result into X
$ Swaps the values of X and Y (general purpose)
# Swaps the values of X and M (selected memory cell)
@ Swaps the values of X and A (memory pointer)
? Swaps the values of A (memory pointer) and I (instruction pointer) if X is not equal to zero

Example Programs

Name Program
Default Infinite Loop: 1+$@0+#1@1?Memory gets filled with numbers sequentially
Countdown User Input: 1-@#+Countdown Loop: 101@1-? Countdown value in C
Multiplication User Input: 1-@#$0@$#0+@#$1@$#+-$Multiplication Loop: 0+-@#+#$+$0+-1@#+1-#10101@0+?Result in Y
Fibonacci Sequence Initialization1@1#Initial memory address is 2 (Stored in Y)10$Add value from previous memory address$+1-@0+-#+$0+#0+-@+1+@0+-#+$+#Add the value from the memory address before that0+-@+10-@0+-#+$0+#0+-@+10+@0+-#+$+#Store next memory address in Y0+-@+1+$Jump back to the start of the loop101@1?

About the Simulator