Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646
Posted: 03:05pm 07 Mar 2021
Copy link to clipboard
Print this post
For when MMBasic won't cut it:
Edited 2021-03-08 01:12 by Tinine
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10215
Posted: 03:15pm 07 Mar 2021
Copy link to clipboard
Print this post
The code as written appears to only ever action case 12
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646
Posted: 03:31pm 07 Mar 2021
Copy link to clipboard
Print this post
If you see the REM, I force it to scan all 12 cases. If I let it action all cases, it's about 2ms quicker:
But now it's not 120,000 scans, obviously. Edited 2021-03-08 01:33 by Tinine
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10215
Posted: 03:36pm 07 Mar 2021
Copy link to clipboard
Print this post
Still not convinced. Every basic normally executes just one CASE and has an implied break.
The first version does 10000 loops of one case and the second seems to do the same given that it executes at the same speed
What happens if you put a second loop?
for i=1 to 10000 for a=1 to 12
select.....
next a next i
PS. Its is a great shame bypic don't post their source as they don't support it anymore. It would really fly if ported to one of the faster chips Edited 2021-03-08 01:39 by matherp
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646
Posted: 04:01pm 07 Mar 2021
Copy link to clipboard
Print this post
In the first example, it's all scanning and no variable incrementing. In the second example, it's less scanning but a variable is being incremented.
I have ByPic for the MX370 @80MHz and 512K flash but I love the DIP 170 and I still have 130K+ flash. Edited 2021-03-08 02:01 by Tinine
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646
Posted: 04:13pm 07 Mar 2021
Copy link to clipboard
Print this post
Paid a penalty for the extra for/next. The inline code is very fast but any sort of a loop incurs a time penalty.