100 ' This idea uses switches that have 3 states either
110 ' up (a number), down (another number), or off(middle position)
120 '
130 ' This programming language does not use a tape, or an array
140 ' of cells. Instead, it uses an internal array of switches.
150 '
160 ' the first switch is #0 which represents the number 0
170 ' the second switch is is #1 which represents either a 1 or 3
180 ' the third switch is is #2 which represents either a 2 or 4
190 ' the fourth switch is is #3 which represents either a 5 or 7
200 ' the fifth switch is is #4 which represents either a 6 or 8
210 ' the sixth switch is is #5 which represents either a 9 or 11
220 ' the seventh switch is is #6 which represents either a 10 or 12
230 ' the eighth switch is is #7 which represents either a 13 or 15
250 '
260 '
270 ' there is no 14 so the programmer would have to use math using
280 ' various numbers to get to 14, 7+7, 15-1, 28/2, 7*2 etc
290 '
300 ' In addition to these switches, there are 4 special memory areas
310 ' which are used to hold values resluting from addition, subtraction,
320 ' multiplication or division. They can be used temporarily and erased.
330 '
340 ' There is a pointer which points to a numbered switch from 0 to 8
350 ' all math functions are done by moving the pointer between the switches
360 ' to point to a specific numbered switch. Then you simply store the number
370 ' represented by the position of the numbered switch whether up down. Switches in the
380 ' middle or off position do not contain a number. By adding, subtracting, multiplying
390 ' or dividing numbers from switches, you arrive at a value that can then be used for
400 ' output or other things.
410 '
420 ' The syntax of switch resembles assembly language.
430 '
440 ' mu or MU moves the pointer up one position. If at 1, it will wrap around back to 7
450 ' md or MD moves the pointer down one position. If at 7, it will wrap around to 1
460 ' a or A starts the addition process.
470 ' s or S starts the subtraction process.
480 ' m or M starts the multiplication process.
490 ' d or D starts the division process.
500 ' ea or EA stops the addition process and wipes the result from memory
510 ' es or ES stops the subtraction process and wipes the result from memory
520 ' em or EM stops the multiplication process and wipes the result from memory
530 ' ed or ED stops the division process and wipes the result from memory
540 ' oa or OA will output the value in the addition memory.
550 ' os or OS will output the value in the subtraction memory.
560 ' om or OM will output the value in the multiplication memory.
570 ' od or OD will output the value in the division memory.
580 ' on or ON will output a new line.
590 '
600 ' Each consecutive a,A,s,S,m,M,d or D command continues the math process.
610 ' a4 adds 4 to the position in memory another a4 makes the value 8
620 ' It works like this so long as you do not use any ea,EA,es,ES,em,EM,ed or ED
630 ' commands. If you have a4, then ea followed by another a4, then the result will
640 ' be 4 because you will have erased the first 4.
650 '
660 ' You can output ascii characters by creating totals that equal to the ascii
670 ' decimal value of the letter to be outputted. If you want a to output a
680 ' blank line, you must use the on or ON command.
690 '
700 ' gi or GI tells the interpreter to get input from the user.
710 ' If you want the input to be specific, then you can use the
720 ' math and output commands to ask the user a question.
730 '
740 ' In addition to the memory storage place for the 4 different math functions,
750 ' there are four more that can store data. These can be used as variables,
760 ' however they do not get a name. You can word with them using the following:
770 '
780 ' s0a or S0A stores the value of "a" in storage unit 0
781 ' s0s or S0S stores the value of "s" in storage unit 0
782 ' s0m or S0M stores the value of "m" in storage unit 0
783 ' s0d or S0D stores the value of "d" in storage unit 0
784 ' s1a or S1A stores the value of "a" in storage unit 1
785 ' s1s or S1S stores the value of "s" in storage unit 1
786 ' s1m or S1M stores the value of "m" in storage unit 1
787 ' s1d or S1D stores the value of "d" in storage unit 1
788 ' s2a or S2A stores the value of "a" in storage unit 2
789 ' s2s or S2S stores the value of "s" in storage unit 2
790 ' s2m or S2M stores the value of "m" in storage unit 2
791 ' s2d or S2D stores the value of "d" in storage unit 2
792 ' s3a or S3A stores the value of "a" in storage unit 3
793 ' s3s or S3S stores the value of "s" in storage unit 3
794 ' s3m or S3M stores the value of "m" in storage unit 3
795 ' s3d or S3D stores the value of "d" in storage unit 3
800 '
830 ' This allows for certain games to be created. Simple though they may be,
840 ' they are still fun. They are considered simple in that they work with
850 ' the 4 storage units that are available.
860 '
870 ' fu or FU flips the switch at the pointer location to up
871 ' fd or FD flips the switch at the pointer location to down
872 ' fo or FO turns on the switch at the pointer location
875 ' fx or FX turns off the switch at the pointer location
876 '
880 ' Begin the inteerpreter
890 '
900 '_fullscreen
910 dim shared switch$
(7,3),x
,tlns
,lnctr
,a
,s
,m
,d
,u0
,u1
,u2
,u3
,p$
(20000),ptr
915 lnctr=1:ptr=0
920 switch$(0,1)="0":switch$(0,2)="0":switch$(0,3)="up"
921 switch$(1,1)="1":switch$(1,2)="3":switch$(1,3)="up"
922 switch$(2,1)="2":switch$(2,2)="4":switch$(2,3)="up"
923 switch$(3,1)="5":switch$(3,2)="7":switch$(3,3)="up"
924 switch$(4,1)="6":switch$(4,2)="8":switch$(4,3)="up"
925 switch$(5,1)="9":switch$(5,2)="11":switch$(5,3)="up"
926 switch$(6,1)="10":switch$(6,2)="12":switch$(6,3)="up"
927 switch$(7,1)="13":switch$(7,2)="15":switch$(7,3)="up"
940 ' Open a file to run
960 if filename$
="" then filename$
="\switch\hello world.switch" 970 x=0
1000 x=x+1
1040 tlns=x
1050 '
1060 ' Parse commands
1260 if p$
(lnctr
)="//" then lnctr
=lnctr
+1:
goto 1060 1340 if p$
(lnctr
)="rp" then ptr
=0:lnctr
=lnctr
+1:
goto 1060
8070 if switch$
(ptr
,3)="up" then a
=a
+val(switch$
(ptr
,1)) else a
=a
+val(switch$
(ptr
,2))
8110 if switch$
(ptr
,3)="up" then s
=s
-val(switch$
(ptr
,1)) else s
=s
-val(switch$
(ptr
,2))
8150 if switch$
(ptr
,3)="up" then m
=m
*val(switch$
(ptr
,1)) else m
=m
*val(switch$
(ptr
,2))
8210 if switch$
(ptr
,3)="up" then d
=d
/val(switch$
(ptr
,1)) else d
=d
/val(switch$
(ptr
,2))
8240 a=0
8270 s=0
8290 m=0
8330 d=0
8510 u0=a
8540 u0=s
8570 u0=m
8600 u0=d
8630 u1=a
8660 u1=s
8690 u1=m
8720 u1=d
8750 u2=a
8780 u2=s
8810 u2=m
8840 u2=d
8870 u3=a
8900 u3=s
8930 u3=m
8960 u3=d
8990 switch$(ptr,3)="up"
9020 switch$(ptr,3)="dn"
9170 print:
print "The pointer is pointing to switch ";ptr;
". Which is in the ";switch$
(ptr
,3);
" Position."