![]() |
Forum Index : Microcontroller and PC projects : BASIC...
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
aFox Senior Member ![]() Joined: 28/02/2023 Location: GermanyPosts: 103 |
Maybe you are also interested in Paul Laughton Paul Laugthon the creator of Atari-Basic and RFO-Basic (Android). I suggest Konsta Kang's version of LineageOs16 (Android 9) for the Raspberry Pi 4. LineageOs16 Gregor Edited 2025-01-07 08:30 by aFox |
||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1360 |
I am experimenting with GOTO for the first time in 40 years. Paradoxically, this particular code looks to be easier to read and way faster than my traditional SELECT CASE approach. Quick example: When I am at step #49 of my sequence, it costs 186µS to evaluate the step number, using select case. With my new method, GOTO gets to the actual code label in 24µS Solves other issues as well without going spaghetti. |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4038 |
The paper about GOTO "considered harmful" was to raise a debate (I think) and helpfully identified bad uses of GOTO. That isn't to say every use is bad and besides if it's _your_ code then do as you will (of course), especially if you need the speed. I can recall FORTRAN code with GOTOs out of and then back into part-done loops, expecting ... well, I shudder to think (OK, I do know but it's horrid and I really didn't write it). MMBasic gives us good code structuring facilities and spaghetti code is hard to read so hooray people tend not to write it! John Edited 2025-01-11 07:38 by JohnS |
||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1360 |
Oh, not a speed issue, we don't have code pointers and so it just irritates me that I have to constantly re-figure where I am in the program 😁 |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4038 |
I must be having a bad day - what are code pointers? And why don't you know where you are in the program? John |
||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1360 |
Code pointer: A = [pointer to a procedure] CALL A Sequence step might = 49 But every iteration, select case Is it 1 Is it 2 Is it 3 etc. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10240 |
fully supported dim calltable$(3)=("sub0","sub1","sub2","sub3") Call calltable$(n) sub sub0 end sub ....... |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2610 |
Re Select Case, it does make the code look tidy and makes it easier to read the code of others but it can, as noted, be slow. In a IR remote control translator / repeater I made where Select Case took the incoming code and selected a new code to send (from a list of 40 or so) had an annoying lag between in and out. The fastest method I found wasted some memory but no noticeable lag. The incoming code was used as an array index and the outgoing code is the value at that index. The codes are essentially random 1 byte values so 256 elements are needed to get the 40 or so codes. Edit. I am a bit slow. Similar concept to Peter's. Edited 2025-01-11 08:57 by phil99 Footnote added 2025-01-11 12:54 by phil99 This method works for any kind of output but the input has to be able to be expressed as an integer. Preferably one not too much bigger than the number of items to be selected as it determines the size of the array. For large floating point numbers it will usually be possible to condense them down to a short integer with some arithmetic. All that is required is each possible input produces a unique output integer. For strings it could be more difficult, unless it is possible to have them include a short identifier code at one end that can be converted to a number. Where that isn't possible the ascii values of some the characters could be used. eg. for the days of the week the first two characters are enough (the last 3 are useless!). Then use some arithmetic to reduce that to a short integer for the index. The key to speed is avoid sorting through a list. Footnote added 2025-01-12 15:08 by phil99 Demo program for above. > LIST 'Demonstrate choosing from a list without searching the list Dim integer day(22), d : Dim s$ 'Number the days starting with Saturday = 0 and assign an index in day() day(10)=0 :day(21)=1 :day(9)=2 :day(22)=3 :day(17)=4 :day(15)=5 :day(0)=6 For n=12 To 18 ' get the day from the date s$=UCase$(Day$(Str$(n)+"-01-2025")) 'insert a date 'condense the day string to a small integer to use as an index for day() d=(Asc(Mid$(s$,1,1))*3+Asc(Mid$(s$,2,1))-Len(s$)-286)\2 Print s$+Space$(9-Len(s$)),, day(d) 'display result Next > > > RUN SUNDAY 1 MONDAY 2 TUESDAY 3 WEDNESDAY 4 THURSDAY 5 FRIDAY 6 SATURDAY 0 > |
||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1360 |
This is scary good and a game changer. How do I not know this? ![]() |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4038 |
Also maybe EVAL or EXECUTE John |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2540 |
how about line numbers and goto? a=integer value goto a no if a= then or case a jokin, stan |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5058 |
In my 10 line Sokoban (TLS) for CMM1, I used 1 (one) line number: 1 (one) In the middle of the program, since a line number 1 uses 1 ascii character, and the shortest label 1 character and 1 colon (i.e. "W:"). Sometimes you must be smart to save 1 byte of of a program..... Volhout PicomiteVGA PETSCII ROBOTS |
||||
Dinosaur![]() Guru ![]() Joined: 12/08/2011 Location: AustraliaPosts: 338 |
Hi All I do and have done so on Rpi Zero for a few years. Rfid login stations on Wifi, Video broadcasting etc. But then FreeBasic has been my "goto" tool for industrial machine control since 2005. I can't get excited about all the optimisation you guys are doing on Pico's. Next year or the year after it will be replaced by something 10x faster and it will probably cost $2 more. With FreeBasic I can put it in any Linux system on numerous micro's. You can be a simpleton with your code or write complex nested code. Granted the complex code can look nothing like Basic and only the author can understand it without spending hours. In the early days I have had to optimise for speed with asm functions, but once I got to 486 boards that fell by the wayside. Regards Regards Hervey Bay Qld. |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2540 |
when I used rpi 1 to 400 I wanted to program it and know only basic so freebasic seemed good idea but couldn't get wiringpi to work. given up with rpi. linux... I've used windows command prompt. it's hell. no one uses it normally. linux terminal it's for casual users to learn to do stuff, set up printer or device... but it's free... so is win 11. each to there own. I'm liking modded win 11 aesthetically.. it's like win 10. daft innit? it's about support for win 10 ending Oct. and moving to win 11 from a pc that ran win 10 fine and is capable of running win 11 fine and ms recognise and allow you to now. posted from optiplex 3020 small pc win 11, core I5, 8G ram, 120Gb ssd, refurbished £70 |
||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1360 |
Almost 40 years on and nothing can do what QB4.5 could. Pause, edit and continue. Immediate mode. I hijacked the PCs clock, reprogrammed it from 55mS to just a couple mS and compensated to preserve correct time. This thing even ran in a quick library (qlb) and shared memory with QB (masm isr, naturally). So whenever I paused the QB execution, I still had the time critical code executing. |
||||
EDNEDN Senior Member ![]() Joined: 18/02/2023 Location: United StatesPosts: 140 |
I think it would be straight forward to add Pause, Edit, Continue to MMBasic. |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7865 |
I think it might be extremely unlikely when development is frozen - unless you do it yourself. ;) You only have 12 versions to support after all. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4302 |
I'm not saying it would be impossible, but it seems exceedingly implausible in MMBasic, for one the EDITor requires the RAM being used by the program you want to CONTINUE. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1360 |
Oh, my comment was a response to the FreeBasic thing. With MMBasic, we can edit/run right on the device. The development cycle is rapid. Making a code change to a remote system, I'd prefer not to involve a compiler. |
||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1360 |
Only just got to my Pico (had to show-up for my own Bday, dammit ![]() Happy chappy, here....This changes a lot for me...Thanks, Pete. ![]() |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |