New BASIC compiler for Prop1 and Prop2

11314161819

Comments

  • Rayman wrote: »
    Looks like you have to do:
    Commands->Configure Commands->P2 Defaults
    to compile for P2...

    Yup, did that when putting in -p COM33

    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
  • My P2 board eval board hasn't arrived yet, so I can't really offer specific help. I would guess that the most likely cause of problems would be timing; the code defaults to a clock frequency of 80 MHz, but I think the P2 Eval board is higher. You could try adding:
    const _clkfreq = 180_000_000
    
    (or whatever the correct maximum clock frequency of the board is.)
  • dgatelydgately Posts: 1,098
    edited 2018-12-22 - 22:07:15
    Running spin2gui in a Win VM, I get the same result as tomcrawford... After the compile, the load seems to complete, but I'm not sure that the code actually executes and I just see the same LEDs lighting and "un-lighting" as Tom.

    When I copy the resultant p2asm code from the spin2gui compiles and paste the code into PNut, it compiles there, but still no results appear (I've tried the blink1 & hello samples, changing the blink1 pin number to 57, modifying the _clkfreq, etc...).

    At the same time, the all_cogs_blink example that comes along with PNut (v32i), runs like a charm! So, I know that the example code, PNut and the P2 all seem to gel... My assumption is that fastspin is not creating a binary that can execute on a real P2 (I assume that it worked on the P2-FPGAs?)

    EDIT: Hopefully helpful, Eric... I am able to use loadp2 (on my VM'ed Win X) to upload the all_cogs_blink.obj that was produced by PNut onto the P2 and it execs just as it does from PNut! Good to know that on Win, loadp2 loads as it should on a real P2.

    dgately

    Livermore, CA (50 miles SE of San Francisco)
  • RaymanRayman Posts: 9,474
    edited 2018-12-23 - 16:22:48
    Is this with real p2?
    You need some extra clock setup instructions in that case...
    See cluso’s 1080p example...
    Looks like hubset #0 will put you in 20mhz rc mode need to do that first looks like but your led should toggle with just that...
    Prop Info and Apps: http://www.rayslogic.com/
  • Rayman wrote: »
    Is this with real p2?
    You need some extra clock setup instructions in that case...
    See cluso’s 1080p example...
    Looks like hubset #0 will put you in 20mhz rc mode need to do that first looks like but your led should toggle with just that...
    Yes, a real P2...
    I did add "hubset #0" but that does not seem to get any fastspin-compiled code to exec, so far.

    "hubset #0" definitely helped get a couple of the examples that came with the Prop2 FPGA files download to work on P2ES. (So, thanks for that info!). Of course, that's using PNut to compile & load.

    I've decided to work on my P2 assembly chops and that's providing success. Got my first experience with interrupts on a propeller chip!
    Livermore, CA (50 miles SE of San Francisco)
  • I'm experiencing the same as dgately; just a data point. Compile and download seems to be proper, no response from P2.
    The difference between theory and practice is that, in theory, there is no difference between theory and practice, but in practice, there is.
  • I think the loader and code needs to be updated for P2 Eval board...
    ozpropdev just posted an updated python loader...
    Prop Info and Apps: http://www.rayslogic.com/
  • The compiler includes a "hubset #$ff" in the generated P2 code. On the FPGA boards that sets the frequency to 80_000_000. I presume that on P2-Eval the frequency is different. Does anyone have a table of hubset values and corresponding frequencies for P2-Eval?
  • Ozpropdev has a nice way of doing it...
    Look for cluso's VGA 1080p example in P2 forum to see...
    Prop Info and Apps: http://www.rayslogic.com/
  • There's a new fastspin release (3.9.14) that fully supports the P2-Eval board. Since this is the BASIC thread, I'll mention the BASIC changes, which are minor:

    - There are now DEFSNG and DEFINT directives to specify the default types for variables whose names start with certain letters. This will make porting code easier from legacy BASICs (where variables defaulted to floating point). For example, you can add
    defsng a-z
    
    at the start of a file to make the default be floating point for variables that are implicitly defined. Variables with an explicit suffix, or with a type given in the DIM statement, are not affected.

    - Multiple statements per line are supported now, so instead of:
      a1 = a2
      b1 = b2
    
    you can write
      a1 = a2 : b1 = b2
    

  • Multiple statements per line! Now it is a BASIC, cool work.

    I know this is a debatable feature, but I always missed that in Spin as well as I miss it in C#.

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • msrobots wrote: »
    Multiple statements per line! Now it is a BASIC, cool work.

    I know this is a debatable feature, but I always missed that in Spin as well as I miss it in C#.

    Mike

    Thanks.

    For even more "BASIC"-ness I guess I should implement support for line numbers. Which, come to think of it, probably wouldn't be too hard (the compiler could conver them automatically into labels). Is it worth it, though?

    Eric
  • well like in FORTRAN?

    Line numbers as labels, but they do not even need to be in order?

    In COBOL line numbers are still supported but nobody would program like that anymore since decades. But if you have a source with line numbers the compiler will still compile it.

    Line numbers can be used with GOTO and GOSUB, maybe ON X GOSUB/GOTO. Where else? So internally allowing labels to be numeric is maybe easy, but I think that this also requires support in Spin2gui for renumbering and such and then things get messy.

    More easy might be to have a option in spin2guy to remove line numbers from a file and replace all 'used' numbers thru autogenerated labels.

    So I could open the original TRS-80 Lunar Lander file, replace all the GOTO NNNN thru some label and have a clean, line numberless source.

    my 2 cents,

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • jmgjmg Posts: 13,531
    ersmith wrote: »
    For even more "BASIC"-ness I guess I should implement support for line numbers. Which, come to think of it, probably wouldn't be too hard (the compiler could conver them automatically into labels). Is it worth it, though?

    Who still uses line numbers, really ?

    Google did find this
    https://www.freebasic.net/forum/viewtopic.php?t=18753
    seems freeBASIC can regress far enough back in time via #LANG "deprecated" to support line numbers.


  • Hi

    Line numbers?
    Yea Gods, please not that.
    I remember the blessed relief when I discovered Qbasic had NO line numbers- heaven.
    Of course if they're optional then all's well....

    Dave
  • msrobots wrote: »
    well like in FORTRAN?

    Line numbers as labels, but they do not even need to be in order?

    Right... if I were to implement them I wouldn't try to force them to be in order, just use them to create automatically generated labels like "_line_010", "_line_020", etc. (And definitely they would not be mandatory!) The idea would be to allow fastspin to compile really old BASIC programs like Lunar Lander. I think we very much want to discourage people from using them in new programs!

  • I recently 'ported' the TRS80 Lunar Lander to @JRetSapDoog's 4 player console using spin.

    I may still have the basic original, have to look.

    Enjoy!

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • here you go
    1000 DIM PLOT$(42):BACK$=CHR$(24)
    1010 PRINT CHR$(21)
    1020 CLS:PRINT @(10,20),"Do you want instructions ?";
    1030 LINE INPUT INS$
    1040 IF ANS$ = "Q" THEN PRINT CHR$(21): RUN "MENU"
    1050 IF INS$="NO" OR INS$="N" THEN GOSUB 2700:PRINT:GOTO 2430
    1060 IF INS$<>"YES" AND INS$<>"Y" THEN GOTO 1020
    1070 CLS
    1080 GOSUB 2700
    1090 PRINT @(9,13),"You are landing a spaceship on an unknown planet and have";
    1100 PRINT @(10,13),"taken over manual control ";H;" feet above a good";
    1110 PRINT @(11,13),"landing spot with a downward velocity of ";V;" ft/sec,";
    1120 PRINT @(12,13),"and ";F;" units of fuel remaining.";
    1130 PRINT @(18,13),
    1140 GOSUB 2660
    1150 PRINT @(2,13),"The following rules govern your spacecraft:";
    1160 PRINT @(5,13),"  (1) After each second, the height, velocity, and";
    1170 PRINT @(6,13)," remaining fuel will be printed, along with a";
    1180 PRINT @(7,13)," plot of the spacecraft height above the";
    1190 PRINT @(8,13)," planet's surface";
    1200 PRINT @(10,13),"  (2) At the right side of the plot, the symbol ':'";
    1210 PRINT @(11,13)," will be typed.  At this point, supply the";
    1220 PRINT @(12,13)," number of units of fuel to be burned in";
    1230 PRINT @(13,13)," the next second.  Each unit of fuel slows";
    1240 PRINT @(14,13)," your descent by 1 ft/sec.";
    1250 PRINT @(16,13)," The maximum thrust of your descent engine";
    1260 PRINT @(17,13)," is 50 units of fuel/sec or 50 ft/sec/sec.";
    1270 PRINT @(20,13),
    1280 GOSUB 2660
    1290 PRINT @(3,13),"  (4) When you make contact with the planet's surface,"
    1300 PRINT @(4,13)," your descent engine will automatically cut";
    1310 PRINT @(5,13)," off and you will be given a report of your";
    1320 PRINT @(6,13)," landing speed and remaining fuel.";
    1330 PRINT @(8,13),"  (5) If you run out of fuel, the ':' will no longer";
    1340 PRINT @(9,13)," be typed out, and the report will automatically";
    1350 PRINT @(10,13)," be given each second until you hit the surface";
    1360 PRINT @(11,13)," of the planet.";
    1365 PRINT @(13,16),STRING$(42,"-");
    1370 PRINT @(14,16),"A velocity of 5 or less will win the game.";
    1375 PRINT @(15,16),STRING$(42,"-");
    1380 PRINT @(20,13),
    1390 GOSUB 2660
    1400 PRINT @(3,18),"List of variables and symbols used;";
    1410 PRINT @(5,18)," T = Elapsed time (Sec):";
    1420 PRINT @(6,18)," H = Height above the planet's surface (ft):";
    1430 PRINT @(7,18)," V = Downward velocity (ft/sec):";
    1440 PRINT @(8,18)," F = Remaining units of fuel:";
    1450 PRINT @(9,18)," : = Units of fuel to be burned during the";
    1460 PRINT @(10,18),"     next second  (Supplied by the user):";
    1470 PRINT @(11,18)," ";CHR$(240);"   Represents your warship:";
    1480 PRINT @(16,23),"The manuevers will now begin...";
    1490 PRINT @(18,25),"G O O D   L U C K ! ! !";
    1500 PRINT @(20,20),
    1510 GOSUB 2660
    1520 CLS
    1530 IF INS$="YES" OR INS$="Y" THEN INS$="N" ELSE GOSUB 2700
    1540 CLS
    1550 PRINT "Time  Height  Vel.  Fuel";
    1560 PRINT SPACE$(16);
    1570 PRINT "Plot of height"
    1580 GRAV=G
    1590 TIME=0
    1600 SHIP$= CHR$(240)
    1610 SHIPALT=H
    1620 SHIPVEL=V
    1630 SHIPFUEL=F
    1640 SHIPPLOT=41
    1650 FOR I=2 TO 40
    1660 PLOT$(I)=" "
    1670 NEXT I
    1680 PLOT$(1)="*"
    1690 PLOT$(41)=SHIP$
    1700 PLOT$(42)="*"
    1710 INITALT=SHIPALT
    1720 PRINT SPACE$(1);
    1730 PRINT USING "##";TIME;:PRINT SPACE$(1);
    1740 PRINT USING "#####.##";SHIPALT;:PRINT SPACE$(1);
    1750 PRINT USING "####";INT(SHIPVEL);:PRINT SPACE$(1);
    1760 IF SHIPFUEL = 0 THEN PRINT " No-fuel  ";
    1770 IF SHIPFUEL > 0 THEN PRINT USING "#####";SHIPFUEL;:PRINT SPACE$(5);
    1780 FOR I=1 TO 42
    1790 PRINT PLOT$(I);
    1800 NEXT I
    1810 IF SHIPFUEL=0 THEN SOUND 1,0: PRINT:SHIPBURN=0:GOTO 1890
    1820 PRINT ":";
    1830 LINE INPUT SHIPBURN$
    1840 IF SHIPBURN$ = "Q" THEN PRINT CHR$(21):RUN "MENU"
    1850 SHIPBURN = VAL(SHIPBURN$)
    1860 SHIPBURN=INT(SHIPBURN)
    1870 IF SHIPBURN<0 OR SHIPBURN>50 THEN GOSUB 2500:GOTO 1830
    1880 IF SHIPBURN>SHIPFUEL THEN SHIPBURN=SHIPFUEL
    1890 ACC=GRAV-SHIPBURN
    1900 VEL=ACC+SHIPVEL
    1910 ALT=SHIPALT-SHIPVEL-.5*ACC
    1920 IF ALT>0 THEN GOTO 2020
    1930 IF ACC=0 THEN TIMEX=SHIPALT/SHIPVEL:GOTO 1990
    1940 X=2*ACC*SHIPALT+SHIPVEL*SHIPVEL
    1950 GOSUB 2580
    1960 TIMEX=(SQRT-SHIPVEL)/ACC
    1970 VEL=ACC*TIMEX+SHIPVEL
    1980 IF VEL<0 THEN GOTO 2020
    1990 IMPACT=1
    2000 TIME=TIME+TIMEX
    2010 GOTO 2050
    2020 IMPACT=0
    2030 SHIPALT=ALT
    2040 TIME=TIME+1
    2050 SHIPFUEL=SHIPFUEL-SHIPBURN
    2060 SHIPVEL=VEL
    2070 IF IMPACT=1 THEN GOTO 2160
    2080 SHIPPLOT=INT(SHIPALT*39/INITALT+2.5)
    2090 IF SHIPPLOT<=1 THEN SHIPPLOT=2
    2100 IF SHIPPLOT<=41 THEN SHIP$=CHR$(240)ELSE SHIPPLOT=41:SHIP$=" "
    2110 FOR I=2 TO 41
    2120 PLOT$(I)=" "
    2130 NEXT I
    2140 PLOT$(SHIPPLOT)=SHIP$
    2150 GOTO 1720
    2160 VEL=INT(SHIPVEL)
    2170 PRINT STRING$(79,CHR$(95))
    2180 IF VEL=0 THEN PRINT "Perfect landing!":GOTO 2270
    2190 IF VEL = 1 THEN PRINT "Good landing!!":GOTO 2270
    2200 IF VEL<=2 THEN PRINT "Slightly bumpy landing.":GOTO 2270
    2210 IF VEL<=4 THEN PRINT "Very bumpy landing.":GOTO 2270
    2220 IF VEL<=5 THEN PRINT "Crunch!! -- You barely made it!":GOTO 2270
    2230 IF VEL<=25 THEN PRINT "Appropriate condolences will be sent to your family.":GOTO 2270
    2240 IF VEL<=50 THEN PRINT "Excessive impact velocity has destroyed the":PRINT "structural integrity of your ship... No air left!"
    2250 IF VEL >50 THEN PRINT "That flash of light visible from the Earth"
    2260 IF VEL >50 THEN PRINT "was your spacecraft vaporizing on impact..."
    2270 PRINT STRING$(79,CHR$(95))
    2280 PRINT "Final velocity; ";VEL;" ft/sec."
    2290 PRINT "Fuel remaining; ";SHIPFUEL;" units."
    2300 PRINT
    2310 IF VEL<=5 THEN PRINT "Congratulations... The general sends his compliments." ELSE PRINT "You have been court martialed."
    2320 PRINT : SOUND 7,0
    2330 PRINT "Do you want to try again ?";
    2340 LINE INPUT ANS$
    2350 IF ANS$ = "Q" THEN PRINT CHR$(21): RUN "MENU"
    2360 IF ANS$="NO" OR ANS$="N" THEN CLS:PRINT CHR$(21):RUN "MENU"
    2370 IF ANS$<>"YES" AND ANS$<>"Y" THEN GOTO 2330
    2380 PRINT "Same initial conditions ?";
    2390 INPUT ANS$
    2400 IF ANS$ = "Q" THEN PRINT CHR$(21):RUN "MENU"
    2410 IF ANS$="YES" OR ANS$="Y" THEN:G=GSAV:H=HSAV:V=VSAV:F=FSAV:GOTO 1540
    2420 IF ANS$<>"NO" AND ANS$<>"N" THEN GOTO 2380
    2430 PRINT "Do you wish to choose initial conditions ?";
    2440 LINE INPUT ANS$
    2450 IF ANS$ = "Q" THEN PRINT CHR$(21):RUN "MENU"
    2460 IF ANS$="NO" OR ANS$="N" THEN GOTO 1520
    2470 IF ANS$<>"YES" AND ANS$<>"Y" THEN GOTO 2430
    2480 GOSUB 2750
    2490 GOTO 1540
    2500 FOR I=1 TO 10
    2510 PRINT BACK$;
    2520 NEXT I
    2530 PRINT SPACE$(9);
    2540 FOR I=1 TO 9
    2550 PRINT BACK$;
    2560 NEXT I
    2570 RETURN
    2580 IF X=0 THEN SQRT=0:RETURN
    2590 IF X<1 THEN X1=2*X ELSE X1=X/2
    2600 X2=.5*(X/X1+X1)
    2610 D=X2-X1
    2620 IF D<0 THEN D=-D
    2630 IF D>.0001 THEN X1=X2:GOTO 2600
    2640 SQRT=X2
    2650 RETURN
    2660 PRINT SPACE$(23); "Press <ENTER> to continue.";
    2670 LINE INPUT Z$
    2680 CLS
    2690 RETURN
    2700 G=.25*(20+RND(121))
    2710 V=30+RND(31)
    2720 H=V*(15+RND(6))
    2730 GOSUB 2970
    2740 RETURN
    2750 PRINT "Gravitational acceleration constant (5-35): ";
    2760 INPUT ANS$
    2770 IF ANS$ = "Q" THEN PRINT CHR$(21): RUN "MENU"
    2780 ANS = VAL(ANS$)
    2790 IF ANS<5 OR ANS>35 THEN GOTO 2750
    2800 G=ANS
    2810 PRINT "Initial velocity (30-60): ";
    2820 INPUT ANS$
    2830 IF ANS$ = "Q" THEN PRINT CHR$(21):RUN "MENU"
    2840 ANS = VAL(ANS$)
    2850 IF ANS<30 OR ANS>60 THEN GOTO 2810
    2860 V=ANS
    2870 HT1=15*INT(V)
    2880 HT2=20*INT(V)
    2890 PRINT "Initial altitude (";HT1;"-";HT2;"): ";
    2900 INPUT ANS$
    2910 IF ANS$ = "Q" THEN PRINT CHR$(21): RUN "MENU"
    2920 ANS = VAL(ANS$)
    2930 IF ANS<HT1 OR ANS>HT2 THEN GOTO 2890
    2940 H=ANS
    2950 GOSUB 2970
    2960 RETURN
    2970 F=10*(1+INT(7*(2*H*G/V+V)/100))
    2980 GSAV=G:HSAV=H:VSAV=V:FSAV=F:RETURN
    2990 END
    
    

    Enjoy!

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • Line numbers can be used with GOTO and GOSUB, maybe ON X GOSUB/GOTO.

    LOL

    GOTO (A*10)+500

    Yeah, I used to do that in Atari BASIC. Honestly, it worked and it was fast. But... well? Maybe not so smart.

    Eric, the question is what kind of BASIC are you making? Are you making a kind of wild BASIC? Could be fun. Maybe some 10 liner contests one day?

    Or, a safer BASIC?



    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • potatohead wrote: »
    Line numbers can be used with GOTO and GOSUB, maybe ON X GOSUB/GOTO.

    LOL

    GOTO (A*10)+500

    Yeah, I used to do that in Atari BASIC. Honestly, it worked and it was fast. But... well? Maybe not so smart.

    Eric, the question is what kind of BASIC are you making? Are you making a kind of wild BASIC? Could be fun. Maybe some 10 liner contests one day?

    Or, a safer BASIC?
    oof. that's really dirty.
    I thought GOTO could only jump to a constant.

    Yeah, I just tried this in TI-BASIC:
     * READY *
    >10 PRINT "HI";
    >20 A=10
    >30 GOTO A
    >RUN
    HI
    
     SYNTAX ERROR IN 30
    >_
    
  • The Amigo (Nuts and Volts Propeller SBC with Basic built in) has goto and gosub to calculated line numbers. It acts as sort of a case statement and is good for menus. (It doesn't help with readability though). I prefer the case statement that is in the fastspin Basic.

    Tom
  • potatohead wrote: »
    Line numbers can be used with GOTO and GOSUB, maybe ON X GOSUB/GOTO.

    LOL

    GOTO (A*10)+500

    Yeah, I used to do that in Atari BASIC. Honestly, it worked and it was fast. But... well? Maybe not so smart.

    Eric, the question is what kind of BASIC are you making? Are you making a kind of wild BASIC? Could be fun. Maybe some 10 liner contests one day?

    Or, a safer BASIC?



    I learned BASIC on a TRS80 and had later on also some ATARIs, but it never occurred to me that you could use expressions for line numbers.

    And I agree with @twm47099 that this is not really readable.

    I actually think that @ersmith is really building a wild-basic here. Or a wild-Spin or wild-C.

    What Eric is doing here is just fantastic.

    You can write your main program in the language of you choice. (if you like brackets use C, else Basic or Spin))
    You can use modules written in any of the 3 supported languages in your main program written in any of the supported languages.
    With ifdefs & co you even can use one set of source files to run on P1 and P2.

    You can write a Basic program for the P1 and use all OBEX spin objects right now. Except of size and some timing adjustments needed since all spin will run now as compiled LMM, not out of the interpreter.

    But all those goodies like the numbers object or FSRW or 4portSerial or graphics.spin + TV or VGA can be used from C like syntax or Basic as well as Spin.

    This is huge.

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • potatohead wrote: »
    Eric, the question is what kind of BASIC are you making? Are you making a kind of wild BASIC? Could be fun. Maybe some 10 liner contests one day?

    Or, a safer BASIC?

    Mainly I'm trying to make a BASIC that's easy to use and does what people with experience with other BASICs would expect. So I guess from one point a view it's a "wild" BASIC.
  • Computed GOTO (like A = 10 : GOTO A) is not going into fastspin, sorry. It would be way too much work for something not used in very many cases.

    Allowing optional line numbers and GOSUB is tempting, since it would allow people to easily port old style programs like from classicbasicgames.org. But there are other missing features (like INPUT, READ, and DATA) that I need to implement first and that'll be more generally useful.

  • jmgjmg Posts: 13,531
    ersmith wrote: »
    Mainly I'm trying to make a BASIC that's easy to use and does what people with experience with other BASICs would expect. So I guess from one point a view it's a "wild" BASIC.
    Sounds good.
    A useful yardstick for any features and documentation is FreeBasic. That also has various Editors and a Debugger, tho not as 'main developer' items.
  • So I guess from one point a view it's a "wild" BASIC.

    YES!

    That warms my heart. It will be fun. I just managed to get hello world done. This end of year was tough!

    Thank you for this work Eric. I believe it will prove more useful than wild.
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • potatoheadpotatohead Posts: 9,715
    edited 2019-01-07 - 18:55:22
    Re: computed GOTO.

    Well, back in the day, I made a text to Morse Code prigram. Was on an Atari. I put a big keyboard buffer into an interrupt routine, so an operator could type ahead.

    I was doing ham radio, novice class and.... well, why not? I did use it to key a transmitter, and would also use it to help improve code for me. I could read it and hear the sound. Would get soneone to input text, so it was new to me. The program could read from a file too.

    The BASIC program ended up being super simple. Computed GOTO took bounds checked ASCII (well, the Atari variant anyway) and would just jump to the routine responsible for that character, then jump back. Super easy, super fast (for BASIC) the bounds checking was also done with expressions.

    I ended up writing a few programs that had almost nothing but expressions. One could do crazy things.

    Later, when that program became assembly language, it worked exactly the same way. (But was shifts and adds, because no multiply on 6502.) But overall, the expressions translated right into neat, fast constructs.

    I have used expressions in this way, off and on, since, and when allowed. When it came up, it was just too simple and fast to ignore.

    For a long time, I thought CASE, SWITCH, ON x GOTO, and friends were for things one could not relate mathmatically!

    Got started on that coke proof keyboard on an Atari 400. Not typing a lot mattered on that thing too. It was terrible. Expressions were flat out easier to input.

    No worries on it beiing valid here. Too wild!

    Just explaining why and where that crazy stuff came from mostly.

    Back then, I honestly had no idea or expectation it would not work. Why else use the numbers? (A young Spud thought) That was about the only thing about line numbers that made any sense! I pretty much hated them otherwise.

    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • Instead of computed gotos in fastspin you can use a table of function (or subroutine) pointers. Something like:
    ''
    '' simple state function demo
    ''
    
    ' type of subroutine to call; for now we do not take any parameters
    ' (but we could)
    type statefunc as sub()
    
    ' declare states for 0-4
    dim state(4) as statefunc
    
    ' simple states may be defined as inline subroutines
    state(0) = sub() : print "in state 0" : end sub
    
    state(1) = sub()
        print "this is state 1"
        print " ... it is more complicated"
        end sub
    
    ' regular subroutines can be used in a state
    sub state2sub()
      print "this is the subroutine for state 2"
      print "it's a simple stand-alone subroutine"
    end sub
    
    state(2) = @state2sub
    
    ' we can also construct subroutines dynamically
    function getstateN(n as integer) as statefunc
      return sub()
        print "this is state "; n
      end sub
    end function
    
    state(3) = getstateN(3)
    state(4) = getstateN(4)
    
    ' run through the states
    ' the BASIC syntax isn't quite rich enough to do indirect calls via arrays yet
    ' so we use a temporary variable
    dim f as statefunc
    for i = 0 to 4
      f = state(i)
      f()
    next i
    
  • @ersmith,

    there is something else I am thinking about. I still want to somehow coexist with TACOZ while programming but it might have other uses too.

    To coexist with TAQOZ one would need to compile and load the binary behind TAQOZ so not starting at HUB $0 but starting at HUB $10000 leaving the first 64K free for TAQOZ.

    The basic Idea would be to run TAQOZ on COG0 and the 'user' program on cog1-7. That would provide the ability to watch and even manipulate a running program.

    Currently I see 2 ways to archive that, one way would be to boot into TAQOZ and then load a binary compiled for ORGH $10000 from TACOZ and start it then in COG1, this would just require to compile as you do now with a different start address.

    The second way would be a binary having most of the first 64 k empty except some code to start cog1 with the program and then gently jmp COG0 into TAQOZ start in ROM.

    And that will overwrite the first 64K HUB out of the ROM.

    COG0 would then run TAQOZ and @Cluso99's Monitor/Debugger in parallel to the user program.

    short:

    could you add some ORGH to your compiler name it BASEADDRESS or something else?

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • Instead of computed gotos in fastspin you can use a table of function (or subroutine) pointers. Something like:

    Nice!

    Lots of toys to play with.
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
Sign In or Register to comment.