Menu
JAQForum Ver 19.10.27

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

   Page 5 of 30    
Posted: 02:15pm
05 Mar 2022
Copy link to clipboard
matherp
Guru

  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
 
Posted: 03:30pm
05 Mar 2022
Copy link to clipboard
darthvader
Regular Member

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.
 
Posted: 04:19pm
05 Mar 2022
Copy link to clipboard
Mixtel90
Guru


  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. :)
 
Posted: 05:12pm
05 Mar 2022
Copy link to clipboard
matherp
Guru

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
 
Posted: 06:10pm
05 Mar 2022
Copy link to clipboard
Turbo46
Guru


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
 
Posted: 06:29pm
05 Mar 2022
Copy link to clipboard
thwill
Guru


  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
 
Posted: 06:56pm
05 Mar 2022
Copy link to clipboard
Turbo46
Guru


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
 
Posted: 07:04pm
05 Mar 2022
Copy link to clipboard
Turbo46
Guru


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

Bill
 
Posted: 07:37pm
05 Mar 2022
Copy link to clipboard
Michal
Senior Member

Hi

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

Michal
 
Posted: 09:24pm
05 Mar 2022
Copy link to clipboard
Volhout
Guru

@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
 
Posted: 09:28pm
05 Mar 2022
Copy link to clipboard
matherp
Guru

  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)
 
Posted: 10:03pm
05 Mar 2022
Copy link to clipboard
Volhout
Guru

@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
 
Posted: 07:47am
06 Mar 2022
Copy link to clipboard
Michal
Senior Member

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
 
Posted: 08:53am
06 Mar 2022
Copy link to clipboard
matherp
Guru

  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
 
Posted: 09:57am
06 Mar 2022
Copy link to clipboard
Michal
Senior Member

  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
 
Posted: 10:19am
06 Mar 2022
Copy link to clipboard
Mixtel90
Guru


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
 
Posted: 10:47am
06 Mar 2022
Copy link to clipboard
matherp
Guru

  Quote  and set up a SETTICK to read it

How do you think settick works?
 
Posted: 11:32am
06 Mar 2022
Copy link to clipboard
Volhout
Guru

I have no idea how complex this is but

PAUSE n (as accurate as is)

SLEEP n (with 10ms inaccuracy)

Volhout
 
Posted: 12:00pm
06 Mar 2022
Copy link to clipboard
thwill
Guru


  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
 
Posted: 02:16pm
06 Mar 2022
Copy link to clipboard
Mixtel90
Guru


  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
 
   Page 5 of 30    
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025