Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:35 27 Nov 2024 Privacy Policy
Jump to

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.

Forum Index : Microcontroller and PC projects : MMBasic for Windows - betas

     Page 5 of 30    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9119
Posted: 02:15pm 05 Mar 2022
Copy link to clipboard 
Print this post

  Quote  with no space lost for variable names, string lengths etc.


CSUbs are stored twice, once as ascii and once as binary so they are actually less  efficient in space than data statements and only just equivalent if they are never read into variables
 
darthvader
Regular Member

Joined: 31/01/2020
Location: France
Posts: 76
Posted: 03:30pm 05 Mar 2022
Copy link to clipboard 
Print this post

Hello Peter  

I just get your beta 0 from github and try to compile , they are 4 errors , when i tried to compile the alpha version everything was OK.
Here the log :




 

I use VS2022 like you.

Cheers.
Theory is when we know everything but nothing work ...
Practice is when everything work but no one know why ;)
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6795
Posted: 04:19pm 05 Mar 2022
Copy link to clipboard 
Print this post

  matherp said  
  Quote  with no space lost for variable names, string lengths etc.


CSUbs are stored twice, once as ascii and once as binary so they are actually less  efficient in space than data statements and only just equivalent if they are never read into variables
Ooh... that's interesting. Not what I expected. In that case I think I'll stick with existing methods. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9119
Posted: 05:12pm 05 Mar 2022
Copy link to clipboard 
Print this post

V5.07.03b3

MMBasic.zip

Should fix most (all?) of the bugs identified above + some others not reported including a complete replacement FFT module (volhout please test)
Implements a lifo stack for read save/restore.

data 0,1,2,3,4,5,6,7,8,9
data 10,11,12,13,14,15,16,17,18,19
dim a(19)
for i=0 to 15
read a(i)
next
subtest1
for i=16 to 19
read a(i)
next
for i=0 to 19
if a(i)<>i then print "error in main",i,a(i)
next
'
sub subtest1
local b(19)
read save
restore s1data
for i=0 to 8
read b(i)
next i
subtest2
for i=9 to 19
read b(i)
next i
for i=0 to 19
if b(i)<>i then print "error in s1",i,b(i)
next
read restore
end sub

sub subtest2
local c(19)
read save
restore s2data
for i=0 to 19
read c(i)
next i
for i=0 to 19
if c(i)<>i then print "error in s2",i,c(i)
next
read restore
end sub


s1data:
data 0,1,2,3,4,5,6,7,8,9
data 10,11,12,13,14,15,16,17,18,19
s2data:
data 0,1,2,3,4,5,6,7,8,9
data 10,11,12,13,14,15,16,17,18,19
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 06:10pm 05 Mar 2022
Copy link to clipboard 
Print this post

There are many things I don't understand and one of them is this kerfuffle over READ, DATA. I get that DATA in an INC file or a SUB can mess up simple READ statements (are you reading the data in the main file, a SUB or the INC file?). But doesn't the proper use of labels and the RESTORE [label] command solve all of that?

See the extracts for 'Conway's Game of Life' from the Welcome tape.

 SELECT CASE k$
   CASE "1" ' glider
     RESTORE seed1
   CASE "2" ' blinker
     RESTORE seed2
   CASE "3" ' toad
     RESTORE seed3
   CASE "4" ' beacon
     RESTORE seed4


' Seeds are pairs of x,y cells ending in -1.
seed1: ' glider
 DATA 4,7,5,7,6,7,6,6,5,5,-1
seed2: ' blinker
 DATA 4,7,5,7,6,7,-1
seed3: ' toad
 DATA 5,7,6,7,7,7,4,8,5,8,6,8,-1
seed4: ' beacon
 DATA 4,7,5,7,4,8,7,9,6,10,7,10,-1
seed5: 'Penta-decathlon

Those parts done by TassyJim if I remember correctly.

There is no data in SUBs or INC files but wouldn't the proper use of labels and the existing RESTORE command avoid any issues? Am I missing something?

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4040
Posted: 06:29pm 05 Mar 2022
Copy link to clipboard 
Print this post

  Turbo46 said  There are many things I don't understand and one of them is this kerfuffle over READ, DATA ...


Very briefly.

1. I've written a utility subroutine that you want to use, e.g. an encryption function.

2. Every time my subroutine is called it wants to READ some DATA that is specifically for that subroutine and nothing to do with your program. Let's say it provides some initial seed or hash that the encrypter requires.

3. Prior to the latest changes if you want to use my subroutine whilst iterating through DATA of your own you have to go through a "song and dance" involving RESTORE and labels in order to maintain your place in your data.

This kerfuffle has been about providing me as the subroutine provider a mechanism by which before I return from my subroutine I can restore the data pointer to the state it was when you called it. That way you don't have to do the "song and dance" and can naively iterate through your DATA in ignorance of the crazy machinations of that difficult Brit.

Hope that helps,

Tom
Edited 2022-03-06 04:30 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 06:56pm 05 Mar 2022
Copy link to clipboard 
Print this post

Hi Tom, I do understand that and Peter's READ SAVE/RESTORE should help if you only need one level of READ SAVE/RESTORE (I think) but.
  Quote  3. Prior to the latest changes if you want to use my subroutine whilst iterating through DATA of your own you have to go through a "song and dance" involving RESTORE and labels in order to maintain your place in your data.

By that are you saying that it could be done using the existing commands? Is it really a 'song and dance'?

Bill
Keep safe. Live long and prosper.
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 07:04pm 05 Mar 2022
Copy link to clipboard 
Print this post

Hi Tom, I have looked at your Crypt.inc file   but that is too much for me to follow.

Bill
Keep safe. Live long and prosper.
 
Michal
Senior Member

Joined: 02/02/2022
Location: Poland
Posts: 123
Posted: 07:37pm 05 Mar 2022
Copy link to clipboard 
Print this post

Hi

I can see Mode -16 is back.
Thanks matherp.

Michal
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4238
Posted: 09:24pm 05 Mar 2022
Copy link to clipboard 
Print this post

@Peter,

Thanks for fixing the FFT. From what I have tested so far all works.
I have no idea what caused it, since you must have used the same source code from CMM2 but anyway, it works now.

Thanks again

Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9119
Posted: 09:28pm 05 Mar 2022
Copy link to clipboard 
Print this post

  Quote  I have no idea what caused it, since you must have used the same source code from CMM2 but anyway, it works now.

CMM2 is C. MMB4W is C++. C++ doesn't support the C complex.h header file but has its own incompatible version. The original got the code to compile but clearly wasn't properly functional. The new version is a C++ specific FFT implmentation (from RossetaCode)
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4238
Posted: 10:03pm 05 Mar 2022
Copy link to clipboard 
Print this post

@Peter,

This is a low prio, but if you have an idea how to do it ....

When MMBasic is started, it uses a certain amount of CPU cycles (on this laptop something like 20%). When you run a program this % increases (the interpreter starts decoding and executing basic commands). On this laptop that is around 50%.

Now I have a program that I want to halt to wait for a key pressed.

do
loop while inkey$=""


It is understandable that the basic interpreter executes these basic commands at top speed, and thus the CPU % is around 50%

do
 pause 100
loop while inkey$=""


During the pause statement the CPU could be sleeping. And thus CPU usage could be lower ?? Is it possible to lower CPU usage this way ?

I am asking this because CPU% means battery usage on a laptop. And when waiting for a key press, we might save time. Or is there a better way to do this ?

P.S. All my testing today is on MMB4W running on Wine (Ubuntu20.04)

Regards,

Volhout
Edited 2022-03-06 08:05 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Michal
Senior Member

Joined: 02/02/2022
Location: Poland
Posts: 123
Posted: 07:47am 06 Mar 2022
Copy link to clipboard 
Print this post

Hi matherp,

Maybe it would be worth adding the full screen and full screan with border options for the current graphics mode of the system?
That's what I thought.

Michal
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9119
Posted: 08:53am 06 Mar 2022
Copy link to clipboard 
Print this post

  Quote  During the pause statement the CPU could be sleeping. And thus CPU usage could be lower ?? Is it possible to lower CPU usage this way ?

It used to be like that but resulted in PAUSE only being accurate to +/- 10mSec so I changed it to be tight looping on the accurate system clock. The same issue with INKEY$ during testing various programs didn't work normally as INKEY$/KEYDOWN response could be delayed by up to 10mSec
 
Michal
Senior Member

Joined: 02/02/2022
Location: Poland
Posts: 123
Posted: 09:57am 06 Mar 2022
Copy link to clipboard 
Print this post

  matherp said  
  Quote  During the pause statement the CPU could be sleeping. And thus CPU usage could be lower ?? Is it possible to lower CPU usage this way ?

It used to be like that but resulted in PAUSE only being accurate to +/- 10mSec so I changed it to be tight looping on the accurate system clock. The same issue with INKEY$ during testing various programs didn't work normally as INKEY$/KEYDOWN response could be delayed by up to 10mSec

This could be a second type of PAUSE for things that do not require a precise clock?

Michal
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6795
Posted: 10:19am 06 Mar 2022
Copy link to clipboard 
Print this post

How about read time into a variable and set up a SETTICK to read it and compare with a >variable? There's no repetitive looping then.
Edited 2022-03-06 20:19 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9119
Posted: 10:47am 06 Mar 2022
Copy link to clipboard 
Print this post

  Quote  and set up a SETTICK to read it

How do you think settick works?
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4238
Posted: 11:32am 06 Mar 2022
Copy link to clipboard 
Print this post

I have no idea how complex this is but

PAUSE n (as accurate as is)

SLEEP n (with 10ms inaccuracy)

Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4040
Posted: 12:00pm 06 Mar 2022
Copy link to clipboard 
Print this post

  Volhout said  I have no idea how complex this is but

PAUSE n (as accurate as is)

SLEEP n (with 10ms inaccuracy)

Volhout


FWIW: a PAUSE in MMB4L does actually sleep and yield (as does waiting for input at the MMBasic prompt) and I accept that MMB4L's timer is not as accurate as that of a 'mite, Linux is not a Real Time Operating System. My TODO list contains the following note "Add option to PAUSE controlling whether it nanosleeps or not, or an OPTION to MMBasic controlling all sleep behaviour".

Peter, thanks for the updates, doing my own thing today but will give MMB4W a good thrash next week.
Bill, will follow up your question tomorrow too.


Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6795
Posted: 02:16pm 06 Mar 2022
Copy link to clipboard 
Print this post

  matherp said  
  Quote  and set up a SETTICK to read it

How do you think settick works?
Forgot - the "interrupts" aren't interrupts.  :(

I plead mitigating circumstances as our toilet cistern cracked very early this morning (it was discovered at 0200) and the bathroom, downstairs hallway and downstairs front room all have water damage to both decorating and contents now.  :(
Edited 2022-03-07 00:22 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
     Page 5 of 30    
Print this page
© JAQ Software 2024