Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:43 16 Nov 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 : CSUBs in 5.06

Author Message
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 06:34pm 09 Dec 2020
Copy link to clipboard 
Print this post

Hi Peter,
when I'm trying to get CSUBs working in 5.06 FW, I'm crashing the CMM2 all the time. Do I need to change somehow the compilation of the CSUB? I'm not using ARMCFunctions.h and I have still arm-gcc-link.ld the same version (2826 byte long).

From this simple code (tried to fix ScrollingText demo):
void FixBytes(long long *scr, long long int *x, long long int *y, long long int *w, long long int *h, long long int *nc)
//'FixBytes screenAdr, X, Y, W, H, newColor
{
char *adr;
adr = (char *)scr;
for (int i = 0; i < 80000; i++)
*adr++ = i & 0xFF;

}


Called from MMBasic with first parameter:
dim integer page1Adr = MM.INFO(PAGE ADDRESS 1)


It crashes the CMM2. The CSUB is
:
CSUB FixBytes
 'FixBytes screenAdr, X, Y, W, H, newColor

 00000000
 'FixBytes
 4A042300 F8003801 33013F01 D1FA4293 BF004770 00013880
END CSUB

Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10590
Posted: 07:43pm 09 Dec 2020
Copy link to clipboard 
Print this post

The issue is the way you are passing scr

Try

void FixBytes(unsigned int *scr)
//'FixBytes screenAdr, X, Y, W, H, newColor
{
char *adr;
adr = (char *)scr[0];
for (int i = 0; i < 80000; i++)
*adr++ = i & 0xFF;

}


Also start CSUB development with optimisation off and only increase it when everything is working. Then you can see if it breaks anything
Edited 2020-12-10 05:58 by matherp
 
RCMAN
Newbie

Joined: 31/10/2020
Location: Canada
Posts: 29
Posted: 01:43pm 10 Dec 2020
Copy link to clipboard 
Print this post

  matherp said  The issue is the way you are passing scr

Try

void FixBytes(unsigned int *scr)
//'FixBytes screenAdr, X, Y, W, H, newColor
{
char *adr;
adr = (char *)scr[0];
for (int i = 0; i < 80000; i++)
*adr++ = i & 0xFF;

}


Also start CSUB development with optimisation off and only increase it when everything is working. Then you can see if it breaks anything



Where can I read about using Csub in my code? And is this documentation current?

Thanks
RC
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10590
Posted: 02:15pm 10 Dec 2020
Copy link to clipboard 
Print this post

Where can I read about using Csub in my code? And is this documentation current?


https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=12289

Is as good as you are going to get
 
RCMAN
Newbie

Joined: 31/10/2020
Location: Canada
Posts: 29
Posted: 03:23pm 10 Dec 2020
Copy link to clipboard 
Print this post

  matherp said  
Where can I read about using Csub in my code? And is this documentation current?


https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=12289

Is as good as you are going to get


Thanks
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 06:34pm 10 Dec 2020
Copy link to clipboard 
Print this post

  matherp said  The issue is the way you are passing scr

Try

void FixBytes(unsigned int *scr)
//'FixBytes screenAdr, X, Y, W, H, newColor
{
char *adr;
adr = (char *)scr[0];
for (int i = 0; i < 80000; i++)
*adr++ = i & 0xFF;

}


Also start CSUB development with optimisation off and only increase it when everything is working. Then you can see if it breaks anything


Thanks,
I will try it.
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
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