PLUS4-AND-OTHERS-RUN-WHO-KNEW-THAT-THIS-KID-IS-ACTUALLY-REALLY-EVIL! -------------------------------------------------------------------------------------------------- TOOL: BASIC 3.5 {Commodore PLUS4} and a lot more as you can see below! Language: BASIC Extra: none Author: Misel Zivanovic Note: (C) 13th of JULY 2026 - www.lived.ch, mzretro.ch --------------------------------------------------------------------------------------------------- After more than 40 years of 8-bit computers, I noticed yesterday one weird thing! I wanted to make sure that a DATA files won't be read the 2nd time you start a program again. And thought, this might be a good idea too {because usually, I am using something else} This looked to me pretty clean code, but it just didn't work! So I told to myself: WHAT THE HECK IS WRONG WITH THIS BASIC 3.5 on COMMODORE PLUS4??? After a while i gave up and thought: Can it be that this is actually like it usually is? Let's try this with all other BASIC versions, including ATARI Turbo XL Basic! And see there, damn, they are all resetting the variable values as soon as you hit RUN! I never noticed that because I always could check the variable values after i hit RUN/STOP! So i thought they are intact... And they were... Until you RUN the program again! I had no idea that this is so! And how things are coming... Try running your program with GOSUB. That shit will work now! An example is at the bottom of this 'normal' RUN examples! CONCLUSION: Because of RUN resetting the variable values, we are never landing where we want to be! HOW DID I MISSED THAT FOR DECADES? Hahaha... Really funny... ======================================= commodore basic v3.5 60671 bytes free 3-plus-1 on key f1 --------------------------------------- 1 ready. 100 if gr=1 then goto 500 120 gr=1 130 a=a+1 140 print a 150 if a>1000 then a=0 160 end 500 print "jumped to here!" 510 print "end of the story!" 520 end ready. print gr 0 ready. run ======================================= **** commodore 64 basic v2 **** 64k ram system 38911 basic bytes free --------------------------------------- 1 ready. 100 if gr=1 then goto 500 120 gr=1 130 a=a+1 140 print a 150 if a>1000 then a=0 160 end 500 print "jumped to here!" 510 print "end of the story!" 520 end ready. print gr 0 ready. run ======================================= commodore basic v7.0 122365 bytes free (c)1986 commodore electronics, ltd. (c)1977 microsoft corp. all rights reserved ---------------------------------------- 1 ready. 100 if gr=1 then goto 500 120 gr=1 130 a=a+1 140 print a 150 if a>1000 then a=0 160 end 500 print "jumped to here!" 510 print "end of the story!" 520 end ready. print gr 0 ready. run ======================================= $$ Commodore-128 COMAL 80 ver 2.02 $$ (C) Copyright UniComal A/S 1984, 1986 (C) Copyright Commodore 1984, 1986 --------------------------------------- list 0100 IF gr=1 THEN msg 0120 gr:=1 0130 a:=a+1 0140 PRINT a 0150 IF a>1000 THEN a:=0 0160 END 0500 PROC msg 0510 PRINT "jumped to here!" 0520 PRINT "end of the story!" 0530 ENDPROC msg run at 0100: gr: unknown variable --------------------------------------- ATARI-800XL - ALTIRRA - EMULATION --------------------------------------- LIST 100 IF GR=1 THEN GOTO 500 120 GR=1 130 A=A+1 140 PRINT A 150 IF A>1000 THEN A=0 160 END 500 PRINT "JUMPED TO HERE!" 510 PRINT "END OF THE STORY!" 520 END READY RUN 1 READY --------------------------------------- =================================================================================================== =================================================================================================== BASICALLY, BASIC LANGUAGE BACK THEN COPIED EACH OTHER AS IT LOOKS and RUN inherited the birth sickness in full length through the long history =================================================================================================== =================================================================================================== =================================================================================================== It also inherited a solution called GOSUB! But who exactly is starting programs with GOSUB? Literally NOBODY! --------------------------------------------------------------------------------------------------- list --------------------------------------- 100 if gr=0 then gosub 500 120 gr=1 130 a=a+5 140 print:print:print:print a 150 if a>1000 then a=0 160 return 500 b=b+1 505 print "jumped to here!";b; 506 print " times" 510 print "end of the story!" 520 return ready. gosub 100 jumped to here! 1 times end of the story! 20 --------------------------------------- --------------------------------------------------------------------------------------------------- =================================================================================================== RUN SOLUTION OF THE PROBLEM! =================================================================================================== =================================================================================================== Well then... How do we do that then? The best is to look at the memory map of each computer and see what's free and unused! Since we are here in the COMMODORE PLUS4 department, we will check that: $02f6-$02fd - decimal 758 - 765 is free and available. That are few bytes we can use for our purposes and we will use tactical battle procedure! First, the chances that there is a number 187 inside of the cell 758 are equal to zero! That is why this is how we will proceed {just one byte is used, of course}: list --------------------------------------- 100 if peek(758)=187 then goto 500 120 poke 758,187 130 a=a+1 140 print:print:print:print:print a 150 if a>1000 then a=0 160 end 500 print "jumped to here!" 510 print "end of the story!" 520 end ready. run jumped to here! end of the story! ready. 1 ready. --------------------------------------- Okay, it's done. You are all dismissed! ---------------------------------------------------------------------------------------------------