Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:36 01 Aug 2025 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 : CMM2: bug in 5.07 - I'm not deliberately looking, honest

     Page 1 of 2    
Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:12am 02 Jul 2021
Copy link to clipboard 
Print this post

I truly wish I hadn't found this, at least Peter can take solace in that it is probably one for Geoff:

> 480MHz Colour Maximite 2 G2
MMBasic Version 5.07.00RC4
Copyright 2011-2021 Geoff Graham
Copyright 2016-2021 Peter Mather

> list "do_loop_bug.bas"
Option Base 0
Option Default None
Option Explicit On

foo(1)

Sub foo(i%)
 Do While i% < 2
   foo(i% + 1)
 Loop
End Sub

> run "do_loop_bug.bas"
Error in line 10: LOOP without a matching DO


Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 10:21am 02 Jul 2021
Copy link to clipboard 
Print this post

I think this is a known issue where you can't use do loops in recursion in this way - certainly the MM2 displays the same symptoms
Edited 2021-07-02 20:33 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:34am 02 Jul 2021
Copy link to clipboard 
Print this post

  matherp said  I think this is a known issue where you can't use do loops in recursion


Thanks Peter, I thought it looked familiar.

Note that to avoid infinite looping foo() should be written:
Sub foo(i%)
 Do While i% < 2
   foo(i% + 1)
   Inc i%
 Loop
End Sub


... which still shows the same problem.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 10:52am 02 Jul 2021
Copy link to clipboard 
Print this post

As Peter said, it is a known issue.  

BASIC is not really suited to recursion.  To allow recursion the current state of the program needs to be pushed onto a stack and, given the way BASIC works, that is a lot of data.  I used some tricks to allow limited recursion but there are problems.

In the Micromite manual I warn against recursing within loops and I should have copied that text across to the CMM2 version.  

Geoff
BTW, I know that "recursing" is not a proper word
Edited 2021-07-02 21:03 by Geoffg
Geoff Graham - http://geoffg.net
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:57am 02 Jul 2021
Copy link to clipboard 
Print this post

Thanks Geoff,

  Geoffg said  BTW, I know that "recursing" is not a proper word


Of course it is, every time I ask Peter for a feature and he says "No" I am "re-cursing" him .

Just kidding,

Tom
Edited 2021-07-02 20:57 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Lodovik

Regular Member

Joined: 17/05/2021
Location: Canada
Posts: 41
Posted: 05:11pm 03 Jul 2021
Copy link to clipboard 
Print this post

Hi,

I have one to report too, discovered by mistake. When I type MODE and press ENTER, my CMM2 freezes up to the point I must do a power cycle. I'm on official 5.07.00 with a 480 MHz unit with no extensions, a pre-assembled Gen1 CMM2 I bought on Micromite.org a month ago.

Thanks.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 05:23pm 03 Jul 2021
Copy link to clipboard 
Print this post

I've added it to the known bug list https://geoffg.net/Downloads/Maximite/CMM2_Current_Bug_List.txt

Will fix in the next release but the workaround is obvious  
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 01:22am 04 Jul 2021
Copy link to clipboard 
Print this post

When I want to implement an algorithm that is fundamentally recursive, and where changing it to purely iterative would substantially "uglify" a nice clean recursion, I just use an explicit stack and push/pop the variables that would change in a real recursion. It's easy, reasonably efficient, and avoids the tight recursion limit.

-Bill
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 04:53am 04 Jul 2021
Copy link to clipboard 
Print this post

Push/Pop is worth thinking about.  There would still be limitations but with the great amount of memory on the CMM2 it might work (but probably not on the Micromites).

I will look into it.

Geoff
Geoff Graham - http://geoffg.net
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 08:34am 04 Jul 2021
Copy link to clipboard 
Print this post

  Quote  Push/Pop is worth thinking about. I will look into it.


Sounds interesting. For the CMM2 I would recommend using VAR PUSH and VAR POP as the commands as I don't have two command slots free (or even one!)
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 09:16am 04 Jul 2021
Copy link to clipboard 
Print this post

Recursion: "If we had an index file, we could look it up in the index file under index file!"
Smoke makes things work. When the smoke gets out, it stops!
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 05:38pm 05 Jul 2021
Copy link to clipboard 
Print this post

The MEMORY command freeze my CMM2 G2 in any option configuration, even after reflashing the firmware with the option to clear all flash memory.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 05:46pm 05 Jul 2021
Copy link to clipboard 
Print this post

  MauroXavier said  The MEMORY command freeze my CMM2 G2 in any option configuration, even after reflashing the firmware with the option to clear all flash memory.


Just vanilla "MEMORY" ? Works on my G2 (prototype):

> 480MHz Colour Maximite 2 G2
MMBasic Version 5.07.00
Copyright 2011-2021 Geoff Graham
Copyright 2016-2021 Peter Mather

> option list
CURRENT VGA mode 800x600 RGB332
CURRENT DISPLAY 50,100
OPTION USBKEYBOARD UK, 1
OPTION RAM ON
OPTION KEYBOARD REPEAT 200,50
OPTION SEARCH PATH /bin/
OPTION F11 chdir "/zmim/src"<crlf>
OPTION F12 chdir "/sptools/src"<crlf>
> memory
Program:
  0K ( 0%) Program (0 lines)
516K (100%) Free

Data:
  0K ( 0%) 0 Variables
  0K ( 0%) General
24800K (100%) Free


Best wishes,

Tom
Edited 2021-07-06 03:47 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 06:12pm 05 Jul 2021
Copy link to clipboard 
Print this post

Just downloaded the binary from Geoff's site and programmed over UART on identical H/W and it works fine.

Try OPTION RESET, if that doesn't work then I suggest you re-program with flash erase all first. Then option reset, then try again

UPDATE: if the problem persists then please type VAR CLEAR and then MEMORY - what happens?

Tom: please try var save/restore on your G2 with and without power cycling
Edited 2021-07-06 04:56 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 07:11pm 05 Jul 2021
Copy link to clipboard 
Print this post

  matherp said  Tom: please try var save/restore on your G2 with and without power cycling


I don't know what I'm looking for, and I didn't find it. All looks good to me.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 11:55pm 06 Jul 2021
Copy link to clipboard 
Print this post

  matherp said  Just downloaded the binary from Geoff's site and programmed over UART on identical H/W and it works fine.

Try OPTION RESET, if that doesn't work then I suggest you re-program with flash erase all first. Then option reset, then try again

UPDATE: if the problem persists then please type VAR CLEAR and then MEMORY - what happens?

Tom: please try var save/restore on your G2 with and without power cycling


After a VAR CLEAR the MEMORY commands works ok, but after a reset I need to use always VAR CLEAR otherwise the system hangs again after the MEMORY command.
Edited 2021-07-07 09:56 by MauroXavier
 
Arno
Newbie

Joined: 19/09/2020
Location: Germany
Posts: 15
Posted: 08:50pm 12 Jul 2021
Copy link to clipboard 
Print this post

I have the same problem as MauroXavier on one of two G2 systems.
Both systems run the same MMBasic Version 5.07.00.

Arno
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 11:09am 13 Jul 2021
Copy link to clipboard 
Print this post

Mauro and Arno

Please could you try the attached experimental version. You won't get the lockup with the memory command. This is easy to fix but the question is does VAR SAVE and VAR RESTORE work?

So please:

A=10
VAR SAVE A

CPU RESTART
VAR RESTORE
? A

You should get 10 on any H/W

Now repeat but power off and on before the VAR RESTORE. Please report both success and any problems

Thanks

Peter


CMM2V5.07.01b1.zip
 
Arno
Newbie

Joined: 19/09/2020
Location: Germany
Posts: 15
Posted: 12:00pm 13 Jul 2021
Copy link to clipboard 
Print this post

Hello Peter,

with power on and CPU RESTART everything worked.

With power off before VAR RESTORE I get the error message,
SAVED VARS CORRUPT - MEMORY CLEARED.

Arno

EDIT:

Direct after power on:
> a=10
> var save a
This freezes the Maximite G2.
Edited 2021-07-13 22:15 by Arno
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 12:21pm 13 Jul 2021
Copy link to clipboard 
Print this post

Arno

Thanks for the info. I can fix the lockup but this still leaves us with the issue of why VAR SAVE doesn't work on a very small number of machines. I've posted on the STM forum to see if anyone has any ideas
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025