June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,34 @@
|
|||
10 GO SUB 1000
|
||||
20 LET e=LEN p$
|
||||
30 LET a$=p$(ip)
|
||||
40 IF a$=">" THEN LET dp=dp+1
|
||||
50 IF a$="<" THEN LET dp=dp-1
|
||||
60 IF a$="+" THEN LET d(dp)=d(dp)+1
|
||||
70 IF a$="-" THEN LET d(dp)=d(dp)-1
|
||||
80 IF a$="." THEN PRINT CHR$ d(dp);
|
||||
90 IF a$="," THEN INPUT d(dp)
|
||||
100 IF a$="[" THEN GO SUB 500
|
||||
110 IF a$="]" THEN LET bp=bp-1: IF d(dp)<>0 THEN LET ip=b(bp)-1
|
||||
120 LET ip=ip+1
|
||||
130 IF ip>e THEN PRINT "eof": STOP
|
||||
140 GO TO 30
|
||||
|
||||
499 REM match close
|
||||
500 LET bc=1: REM bracket counter
|
||||
510 FOR x=ip+1 TO e
|
||||
520 IF p$(x)="[" THEN LET bc=bc+1
|
||||
530 IF p$(x)="]" THEN LET bc=bc-1
|
||||
540 IF bc=0 THEN LET b(bp)=ip: LET be=x: LET x=e: REM bc will be 0 once all the subnests have been counted over
|
||||
550 IF bc=0 AND d(dp)=0 THEN LET ip=be: LET bp=bp-1
|
||||
560 NEXT x
|
||||
570 LET bp=bp+1
|
||||
580 RETURN
|
||||
|
||||
999 REM initialisation
|
||||
1000 DIM d(100): REM data stack
|
||||
1010 LET dp=1: REM data pointer
|
||||
1020 LET ip=1: REM instruction pointer
|
||||
1030 DIM b(30): REM bracket stack
|
||||
1040 LET bp=1: REM bracket pointer
|
||||
1050 LET p$="++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>+++++.": REM program, marginally modified from Wikipedia; outputs CHR$ 13 at the end instead of CHR$ 10 as ZX Spectrum Basic handles the carriage return better than the line feed
|
||||
1060 RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue