Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:30 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 : MMBasic for Android

Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:28am 11 Sep 2021
Copy link to clipboard 
Print this post

Not something I'm actively working on but in an idle 30 minutes this morning:

   

MMBasic is running natively on the phone (I'm not cheating by logging into a Linux box). Terminal emulation is provided by the Termux app.

Whilst I can run commands at the command line it won't list or run programs "in flash" at the moment. I don't expect it will be difficult to flush out the issue when I come back to it ... perhaps some bad pointer cast somewhere.

Other Android BASICs may be available

Tom
Edited 2021-09-11 20:31 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:29am 11 Sep 2021
Copy link to clipboard 
Print this post

... it may also be a battery killer because of its 100% CPU usage ... like the PicRoMite if memory serves.

Best wishes,

Tom
Edited 2021-09-11 21:00 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 12:17pm 11 Sep 2021
Copy link to clipboard 
Print this post

Whoa, this could be awesome.

To be able to program MMBasic for a device that is packaged and ready to install, would open up all kinds of possibilities.





 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 07:57pm 11 Sep 2021
Copy link to clipboard 
Print this post

All these backpacks that are designed around PIC and STM32 chips running MMBasic are basically targetting this product. USB (keyb+mouse and terminal), serial (2x), ethernet, and discrete IO. Most likely 24V in / relay out. This is just perfect.

Nice.....
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:42am 20 Sep 2021
Copy link to clipboard 
Print this post

<Dances a happy dance>

I actually got it "properly" working on Android .

There is a subtle bug in the heap initialisation code for MMBasic for DOS (which MMB4L is based upon):

// memory for the actual heap
char MMHeap[HEAP_SIZE];

#define RAMEND   (MMHeap + HEAP_SIZE)

void InitHeap(void) {
   ...
   MBitsSet((char *) RAMEND, PUSED | PLAST);
}


Peter, Geoff, I looked, but because of differences in how the memory works for the 'mites it wasn't immediately obvious if the same issue existed on the other platforms - you might want to check.

Best wishes,

Tom
Edited 2021-09-20 21:11 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: 11:48am 20 Sep 2021
Copy link to clipboard 
Print this post

Not sure what you think the bug is? There is no issue AFAIK as long as the map array is big enough. Otherwise you lose 256bytes of heap if you set
RAMEND = MMHeap + HEAP_SIZE - PAGESIZE
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 12:09pm 20 Sep 2021
Copy link to clipboard 
Print this post

  matherp said  Not sure what you think the bug is? There is no issue AFAIK as long as the map array is big enough. Otherwise you lose 256bytes of heap if you set
RAMEND = MMHeap + HEAP_SIZE - PAGESIZE


Now I have to double-check to see that I am not being an idiot ...

Thank you, it's more complex than I thought, but it's still an issue:
#define RAMEND   (MMHeap + HEAP_SIZE)


Means that RAMEND is the address of the byte immediately after MMHeap[].

As a result calling:
MBitsSet((char *) RAMEND, PUSED | PLAST);

writes to the byte immediately after the end of mmap[] - i.e. the write overflows.

And it just so happens that when compiled on Termux/Android that byte is the first byte of ProgMemory, which explains why stored programs wouldn't run.

Do I make sense, or am I still talking cobblers ?

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: 12:26pm 20 Sep 2021
Copy link to clipboard 
Print this post

  Quote  writes to the byte immediately after the end of mmap[]

Only if mmap is set to exact size - I just set it slightly bigger
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 12:30pm 20 Sep 2021
Copy link to clipboard 
Print this post

  matherp said  
  thwill said  writes to the byte immediately after the end of mmap[]


Only if mmap is set to exact size - i just set it slightly bigger


Glad to hear it, but MMBasic for DOS does not and that's the bug. I was just practicing due diligence and reporting it in case the same mistake existed in other MMBasic implementations ... or I could keep these things to myself and let others flail around with their debugger .

Best wishes,

Tom
Edited 2021-09-20 22:44 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: 12:37pm 20 Sep 2021
Copy link to clipboard 
Print this post

On the PicoMite I don't even use MBitsSet((char *) RAMEND, PUSED | PLAST);
I just clear mmap completely. GetMemory only looks at the Heap from RAMEND-PAGESIZE down so the fact that there is no PUSED/PLAST bits set is irrelevant
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 12:45pm 20 Sep 2021
Copy link to clipboard 
Print this post

  thwill said  ... and let others flail around with their debugger .


And trying to use gdb on a 5" Android phone screen is not any fun. Then I worked out how to start an ssh daemon on my phone which solved the problem, but left me rather uneasy about how it is possible to run an ssh daemon on an unrooted phone.

Best wishes,

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

Guru

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

  matherp said  On the PicoMite I don't even use MBitsSet((char *) RAMEND, PUSED | PLAST);
I just clear mmap completely. GetMemory only looks at the Heap from RAMEND-PAGESIZE down so the fact that there is no PUSED/PLAST bits set is irrelevant


Thanks, I'll look into that when I finalise the "fix" for MMB4L.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025