User Tools

Site Tools


sd-8516_user_s_guide

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sd-8516_user_s_guide [2026/02/20 20:49] – created appledogsd-8516_user_s_guide [2026/02/21 10:20] (current) appledog
Line 15: Line 15:
 Type this right now (press ENTER after the line): Type this right now (press ENTER after the line):
  
-    ? "HELLO WORLD"+<codify BASIC> 
 +? "HELLO WORLD" 
 +</codify>
  
 The computer should immediately display: The computer should immediately display:
Line 23: Line 25:
 Now try: Now try:
  
-    ? 42 + 8+<codify BASIC> 
 +? 42 + 8 
 +</codify>
  
 It prints 50. You can do math right away, no program needed. This is called **direct mode,** directly entering commands on the terminal. It prints 50. You can do math right away, no program needed. This is called **direct mode,** directly entering commands on the terminal.
Line 34: Line 38:
 Now carefully type these lines (press ENTER after each one): Now carefully type these lines (press ENTER after each one):
  
-    10 "HELLO WORLD" +<codify BASIC> 
-    20 GOTO 10+10 PRINT "HELLO WORLD" 
 +20 GOTO 10 
 +</codify>
  
 Type **RUN** and press ENTER. Type **RUN** and press ENTER.
Line 48: Line 54:
 You don't have to type lines in order, the computer will sort them for you automatically. Try this: You don't have to type lines in order, the computer will sort them for you automatically. Try this:
  
-    20 ? "LINE 20 COMES FIRST ANYWAY!" +<codify BASIC> 
-    10 ? "BUT LINE 10 RUNS FIRST"+20 ? "LINE 20 COMES FIRST ANYWAY!" 
 +10 ? "BUT LINE 10 RUNS FIRST" 
 +</codify>
  
 **RUN** **RUN**
Line 67: Line 75:
 Try this in direct mode: Try this in direct mode:
  
-    LET A = 25 +<codify BASIC> 
-     +LET A = 25 
-    ? A+ 
 +? A 
 +</codify>
  
 It prints 25. It prints 25.
Line 75: Line 85:
 Now a tiny counting program: Now a tiny counting program:
  
-    10 LET A = 1 +<codify BASIC> 
-    20 ? A +10 LET A = 1 
-    30 LET A = A + 1 +20 ? A 
-    40 IF A <= 10 THEN GOTO 20 +30 LET A = A + 1 
-    50 ? "BLAST OFF!"+40 IF A <= 10 THEN GOTO 20 
 +50 ? "BLAST OFF!" 
 +</codify>
  
 **RUN** **RUN**
Line 110: Line 122:
 Add these lines to make a simple checker: Add these lines to make a simple checker:
  
-    40 IF E = 42 THEN GOTO 70 +<codify BASIC> 
-    50 IF E <> 42 THEN ? "TRY AGAIN!" +40 IF E = 42 THEN GOTO 70 
-    60 GOTO 10 +50 IF E <> 42 THEN ? "TRY AGAIN!" 
-    70 PRINT "YOU FOUND THE ANSWER!"+60 GOTO 10 
 +70 PRINT "YOU FOUND THE ANSWER!" 
 +</codify>
  
 **RUN** and try a guess until you hit 42. (42 is a reference to the Hitchhiker's Guide -- a great book). **RUN** and try a guess until you hit 42. (42 is a reference to the Hitchhiker's Guide -- a great book).
Line 132: Line 146:
 40 LET A = 1  40 LET A = 1 
 50 LET B = 100 50 LET B = 100
- +60 LET D = RAND( B - A + 1 ) + A - 1   : REM SECRET NUMBER! 
-FIXME +70 LET F = 0 
-UNDER CONSTRUCTION +80 LET F = F + 1 
- +90 PRINT "" 
-60 D = RAND( B - A + 1 ) + A - 1   : REM SECRET NUMBER! +100 PRINT "ROUND";
-70 F=0 +110 PRINT "LOW:";A;" HIGH:";B
-80 F=F+1 +
-90 "" +
-100 "ROUND";+
-110 "LOW:";A;" HIGH:";B+
 120 INPUT "YOUR GUESS:"; E 120 INPUT "YOUR GUESS:"; E
-130 IF E>B THEN "TOO LARGE!":GOTO 90 +130 IF E > B THEN PRINT "TOO LARGE!" : GOTO 90 
-140 IF E<A THEN "TOO SMALL!":GOTO 90 +140 IF E < A THEN PRINT "TOO SMALL!" : GOTO 90 
-150 IF E<D THEN "HIGHER!":A=E:GOTO 80 +150 IF E < D THEN PRINT "HIGHER!"LET A = E : GOTO 80 
-160 IF E>D THEN "LOWER!":B=E:GOTO 80 +160 IF E > D THEN PRINT "LOWER!"LET B = E : GOTO 80 
-170 "YOU GOT IT!" +170 PRINT "YOU GOT IT!" 
-180 "SCORE:";101-F +180 PRINT "SCORE:";101-F 
-190 "PLAY AGAIN? (Y/N)" +190 PRINT "PLAY AGAIN? ( 1=Y / 0=N ) "; 
-200 INPUT G$ +200 INPUT G 
-210 IF G$="Y" THEN GOTO 50 +210 IF G = THEN GOTO 50 
-220 "BYE FOR NOW!"+220 PRINT "BYE FOR NOW!"
 </codify> </codify>
  
Line 159: Line 169:
 This is the spirit of 8-bit BASIC—type it in, play it, tweak it, make it yours. Just like the old days when you'd stay up late copying listings from magazines. This is the spirit of 8-bit BASIC—type it in, play it, tweak it, make it yours. Just like the old days when you'd stay up late copying listings from magazines.
  
-**What's Next?** +==IF-THEN EXAMPLE
- +
-You've got the basics: PRINT/?, variables, math (+ - * /), GOTO, IF-THEN, INPUT, and RAND(). For more power, check the **SD-8516 Programmer's Reference Guide**—it covers GOSUB/RETURN (coming soon), FOR-NEXT loops, PEEK/POKE for memory fun, and future plans like strings (A$), sound, and even graphics commands. +
- +
-Experiment! Change the messages, make the range bigger, add more hints. That's how so many great games started back in the day. +
- +
-Happy programming, space cadet—your SD-8516 is ready for adventure! +
- +
- +
-== GOSUB +
-Welcome back to Stellar BASIC on your SD-8516! We're building on the classic Tiny BASIC spirit from 1975; small, fast, and full of that pure home-computer magic. Type in a few lines, hit RUN, and watch your creation come to life! +
- +
-Stellar BASIC keeps things simple: integer math only, single-letter variables (A–Z), line-numbered programs, PRINT, INPUT, and IF+
- +
-Here are some BASIC commands you can try right when you turn on your computer: +
- +
-PRINT "HELLO WORLD!" +
- +
-    LET A = -5            ( This sets A to 5 ) +
-    PRINT A               ( This will print 5 ) +
-    PRINT A*2             ( Prints 10 ) +
 Here is an example program: Here is an example program:
  
-    10 LET A = 5   +<codify BASIC> 
-    20 PRINT A   +10 LET A = 5   
-    30 LET A = A - 1   +20 PRINT A   
-    40 IF A > 0 THEN GOTO 20   +30 LET A = A - 1   
-    50 PRINT "GOAL!"+40 IF A > 0 THEN GOTO 20   
 +50 PRINT "GOAL!" 
 +</codify>
  
 Next, type **RUN.** You will see a countdowns to 1, then "GOAL!" Next, type **RUN.** You will see a countdowns to 1, then "GOAL!"
Line 198: Line 189:
 Here is an example of a GOSUB helper function: Here is an example of a GOSUB helper function:
  
-    10 REM GOSUB SQUARE DEMO +<codify BASIC> 
-    20 LET A = 2 +10 REM GOSUB SQUARE DEMO 
-    30 GOSUB 1000 +20 LET A = 2 
-    40 LET A = 3 +30 GOSUB 1000 
-    50 GOSUB 1000 +40 LET A = 3 
-    60 LET A = 4 +50 GOSUB 1000 
-    70 GOSUB 1000 +60 LET A = 4 
-    80 LET A = 5 +70 GOSUB 1000 
-    90 GOSUB 1000 +80 LET A = 5 
-    100 GOTO 9000 +90 GOSUB 1000 
-    9000 REM END+100 GOTO 9000 
 +9000 REM END
  
-    1000 REM THIS HELPER FUNCTION WILL PRINT THE SQUARE OF A +1000 REM THIS HELPER FUNCTION WILL PRINT THE SQUARE OF A 
-    1010 PRINT A * A +1010 PRINT A * A 
-    1020 RETURN+1020 RETURN 
 +</codify>
  
 After you enter this program and type RUN, you will see the result 4, 9, 16, 25. As you can see, every time the program calls **GOSUB 1000,*** it runs the code at LINE NO 1000 and then **RETURN**s to continue in the main program. After you enter this program and type RUN, you will see the result 4, 9, 16, 25. As you can see, every time the program calls **GOSUB 1000,*** it runs the code at LINE NO 1000 and then **RETURN**s to continue in the main program.
Line 224: Line 217:
 **NEW** then type: **NEW** then type:
  
-10 ""  +<codify BASIC> 
 +10 PRINT ""  
 20 GOSUB 900   : REM SHOW INSTRUCTIONS   20 GOSUB 900   : REM SHOW INSTRUCTIONS  
 30 A=1 : B=100   30 A=1 : B=100  
Line 242: Line 236:
 150 GOSUB 400   150 GOSUB 400  
 160 ? "SCORE:";101-F   160 ? "SCORE:";101-F  
-170 ? "PLAY AGAIN? (Y/N)"   +170 ? "PLAY AGAIN? (Y=1/N-0)"   
-180 INPUT G  +180 INPUT G   
-190 IF G$="Y" OR G$="y" THEN GOTO 30  +190 IF G = THEN GOTO 30  
 200 ? "THANKS FOR PLAYING!"   200 ? "THANKS FOR PLAYING!"  
-210 END  +210 GOTO 5000
  
 400 ? "YOU GOT IT IN";F;" GUESSES!"   400 ? "YOU GOT IT IN";F;" GUESSES!"  
Line 268: Line 262:
 930 ? "I'LL TELL YOU HIGHER OR LOWER."   930 ? "I'LL TELL YOU HIGHER OR LOWER."  
 940 RETURN 940 RETURN
 +5000 REM END
 +</codify>
  
-**RUN** — Play a few rounds! The subroutines make it modular—if you want fancier win/lose messages later, just edit those GOSUB lines.+Try to **RUN** this program and play a few rounds! The subroutines make it modular. If you want fancier win/lose messages later, just edit those GOSUB lines.
  
 **Negative Numbers in Action** **Negative Numbers in Action**
Line 275: Line 271:
 Since negatives are fully supported, try tweaking the game or make a countdown timer: Since negatives are fully supported, try tweaking the game or make a countdown timer:
  
-10 "COUNTDOWN FROM ZERO..."   +<codify BASIC> 
-20 A=0   +10 PRINT "COUNTDOWN FROM ZERO..."   
-30 A   +20 LET A = 0   
-40 A=A-1   +30 PRINT A   
-50 IF A>=-10 THEN GOTO 30   +40 LET A = A - 1   
-60 "BLAST OFF INTO NEGATIVE SPACE!"+50 IF A >= - 10 THEN GOTO 30   
 +60 PRINT "BLAST OFF INTO NEGATIVE SPACE!" 
 +</codify>
  
-**What's Next?**+=== WHILE, DO-WHILE, and FOR-NEXT Part I 
 +Stellar BASIC V1 keeps things simple and fast; no built-in FOR-NEXT or WHILE (yet! --they're coming in future updates). But you can create powerful repeating loops using just IF...THEN and GOTO, plus a counter variable when needed. This section will demonstrate the kind of clever thinking you will need to write advanced programs in TinyBASIC.
  
-You've now got the core toolkit: ?, variables (with negatives!), INPUT, IF-THENGOTO, RAND(), and GOSUB/RETURN for structured programsExperiment wildly—change messagesadd more subroutinesmake the range -50 to 50 for negative guesses!+The key tricks: 
 + 
 +* WHILE -- A while loop checks the condition first, so place the IF check before the loop body. 
 +* DO-WHILE -- A do loop runs at least once, so place the IF check at the end of the loop body. 
 +* FOR-NEXT -- A for-next is essentially a WHILE loop (see below). 
 + 
 +Let's see these in action with short examples you can type in right now
 + 
 +==== WHILE 
 +WHILE is short for WHILE-DO. The loop check is at the front of the do-loop (so it may skip the loop entirely). This is like "while something is true, keep doing the body." 
 + 
 +ExamplePrint numbers from 1 to 5, checking first. 
 + 
 +<codify BASIC> 
 +10 LET I = 1 
 +20 IF I > 5 THEN GOTO 60 
 +30 
 +40 LET I = I + 1 
 +50 GOTO 20 
 +60 ? "DONE!" 
 +</codify> 
 + 
 +This prints 1 through 5. If you change line 10 to LET I=10it skips the printing entirely, since the condition was false when we checked the loop condition (at the front of the loop body)
 + 
 +==== DO-WHILE 
 +In this style the do-loop is executed and then if the condition (the while) passesit executes the loop again. This style of loop always runs at least once. 
 + 
 +Example: Keep asking for a positive number until you get one. 
 + 
 +<codify BASIC> 
 +10 INPUT "ENTER A POSITIVE NUMBER "
 +20 IF N > 0 THEN GOTO 40 
 +30 PRINT "TRY AGAIN – MUST BE POSITIVE!" 
 +40 IF N <= 0 THEN GOTO 10 
 +50 PRINT "THANKS! YOU ENTERED "; N 
 +</codify> 
 + 
 +This program runs the INPUT at least once. If you enter -5it complains and loops back. If positive, it exits. The check is at the bottom; no skip on first pass. 
 + 
 +==== FOR-NEXT 
 +Here, the FOR idea is to iterate over a range, and the NEXT check usually occurrs at the front of the loop (but may also occurr at the end of the loop)
 + 
 +Example: Countdown from 10 to 0check at top. 
 + 
 +<codify BASIC> 
 +10 LET C = 10 
 +20 IF C >= 0 THEN GOTO 40 
 +30 GOTO 70 
 +40 PRINT C 
 +50 LET C = C - 1 
 +60 GOTO 20 
 +70 PRINT "IGNITION!" 
 +</codify> 
 + 
 +Observe that sometimes flipping the logic of the test makes the code cleaner (no extra check): 
 + 
 +<codify BASIC> 
 +10 LET C = 10 
 +20 IF C < 0 THEN GOTO 60 
 +40 PRINT C 
 +50 LET C = C - 1 
 +60 GOTO 20 
 +70 PRINT "IGNITION!" 
 +</codify> 
 + 
 +In this second caseinverting the logic falls-through to the do-loop. This is more efficienteven though the idea is "if C is greater than or equal to zero". Know your logic operators! 
 + 
 +==== FOR-NEXT part II 
 +Here is another example of a similar loop, that amounts to a FOR-NEXT loop. 
 + 
 +Example: Print even numbers 2 to 20 (step +2). 
 + 
 +<codify BASIC> 
 +10 LET X = 2 
 +20 IF X > 20 THEN GOTO 60 
 +30 PRINT X 
 +40 LET X = X + 2 
 +50 GOTO 20 
 +60 PRINT "EVEN NUMBERS DONE!" 
 +</codify> 
 + 
 +Or, to simulate STEP -1 (countdown), as before, 
 + 
 +<codify BASIC> 
 +10 LET Y = 20 
 +20 IF Y < 1 THEN GOTO 60 
 +30 PRINT Y 
 +40 LET Y = Y - 1 
 +50 GOTO 20 
 +60 PRINT "BLAST OFF!" 
 +</codify> 
 + 
 +These methods of program flow control are from old-school TinyBASIC programming. This was the norm -- inventive uses of code. There is a LOT you can do with TinyBASIC. It's understandable, and very efficient. 
 + 
 +=== An Exercise for the Reader 
 + 
 +You can practice your BASIC skills with these exercises: 
 + 
 +* Make the WHILE example count backwards. 
 +* Turn the guessing game's round counter into a DO-style loop (run at least one round?). 
 +* Add a "Play again?" wrapper around your game. 
 + 
 +When FOR-NEXT arrives in a future update, you'll appreciate how these hand-built loops taught you control flow. Until then, don't forget to "think differently!
 + 
 +== NEXT STEPS 
 +**What's Next?**
  
-Check the **SD-8516 Programmer's Reference Guide** for deeper detailsupcoming FOR-NEXT loopsPEEK/POKE for peeking at memory (classic retro fun)string variables (A$), sound commands, and more. The roadmap is alive—your ideas help shape it.+You've now got the core toolkitPRINT, LET variables, INPUT, IF-THENGOTORAND(), and GOSUB/RETURN for structured programsExperiment wildly, change freely-- add more subroutines, make the range -50 to 50 for negative guesses, introduce more features!
  
-Keep typing, keep tweaking. That's how the best 8-bit adventures were born. You're in the cockpit now, space cadet—make the SD-8516 shine!+You are in the driver's seat now! Worlds of adventure await your discovery!
  
----+//Check the **SD-8516 Programmer's Reference Guide** for deeper details including a roadmap for upcoming FOR-NEXT loops, PEEK/POKE for peeking at memory (classic retro fun), string variables (A$), sound commands, and more.//
  
-This update feels natural and progressive: starts with quick negative demo, adds GOSUB gently with a standalone example, then shows it in a real (improved) program. Keeps the page count reasonable for a User's Guide tutorial section. Let me know if you'd like more examples, a separate advanced subroutine section, or tweaks! 🚀 
sd-8516_user_s_guide.1771620544.txt.gz · Last modified: by appledog

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki