wishlist for NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: wishlist for NXC

Post by mattallen37 »

I'm not sure how you (someone) would go about it. I do remember hearing about how messy the FW is though, so it might be possible. John said that it would take a ton of work to rewrite it, and he doesn't have the time to attempt something like that. If you really need faster processing, there are options available.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

matt,
thanks, but this is my wish (or actually a question to John) for the wish list, not for a discussion thread.
I found that RobotC works really faster (min 10x) in direct comparison and I remember correctly that they "have stolen much from the NQC API" (ref: John Hansen) so I'm curious if NXC can get some profits of it's techniques.
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: wishlist for NXC

Post by muntoo »

doc-helmut wrote:so I'm curious if NXC can get some profits of it's techniques.
Nope (for the "10x fast") - that would mean modifying the firmware. It can, however, be optimized to 3x fast by improving the output of the NBC code. I'd prefer that method to the firmware changing.

EDIT: Adding to my non-expert guesses. ;)
doc-helmut wrote:is there a chance to speed up the enh FW in relation to the std FW ?
Well, he has added natively supported bitwise operations, but short of changing a whole bunch of internal stuff, and rewriting the FW, I doubt it.
Last edited by muntoo on 15 Jun 2011, 16:07, edited 1 time in total.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

muntoo,
I'm not sure if you're such an expert for the VM and FW details, so I'd like to hear something from a "real specialist" - even if the answer should be coincidentally the same as yours ...
doc-helmut wrote:is there a chance to speed up the enh FW in relation to the std FW ?
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: wishlist for NXC

Post by muntoo »

Proper support for the following:

Code: Select all

++foo[i]; // EDIT: According to the operator precedence table, this may be undefined behavior in C.
++(foo[i]);
(foo)[i] = 1;
++(i);
This doesn't compile:

Code: Select all

task main()
{
	int foo[1];
	++foo[0];
}
Not necessary, but a few more ideas:

Code: Select all

(foo+i) = 1;
int* bar = &foo; // Notice: bar points directly to foo; no "runtime stuff" is needed. It's an "alias", in other words. Kind of like passing-by-reference.
*bar = 1;
NXC should be able to determine and "disambiguate" this, even without pointers!
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: wishlist for NXC

Post by muntoo »

Static electricity!

Code: Select all

static int foo;
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

support for
volatile
to prevent the compiler from faulty optimizations
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: wishlist for NXC

Post by muntoo »

As Spiller describes in this post:
spillerrec wrote:As shown in muntoos post, you have to be very careful when you are dealing with large strings/arrays because it ends up making temporary variables.
To make matters worse, in NBC there is no such thing as scope, all variables are global/static so even when it goes out of scope in NXC it does not get cleared. And it is "impossible" to clear them, since you don't have access to them. (Well, there is a dirty trick, run the function again but with an empty array, depending on the function you might be able to clear most of them.)
This is something that should be fixed - it limits our memory use significantly. Could you generate NBC code which reinitializes the arrays only in scope of the block at the end of the block?

Code: Select all

{ // start block
    string c = a + b;
    //...
} // end block
To:

Code: Select all

// start block
    strcat c, a, b
    //...
    arrinit c, 0, 0
// end block
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
spillerrec
Posts: 358
Joined: 01 Oct 2010, 06:37
Location: Denmark
Contact:

Re: wishlist for NXC

Post by spillerrec »

Is it possible to add the possibility to manually limit FontTextOut() when using DRAW_OPT_FONT_WRAP?
If you want to make something like a border around the text, or a scrollbar in the right side for example it is fairly important to prevent the text overlapping this.

But this is actually not what I want to use it for (since I already have implemented this in my word-wrapping library (which also makes it possible to control which lines should be drawn)). I often use FontTextOut() to replace certain GraphicOut() operations but I often end up having to do the wrapping manually. In my slide puzzle game I needed to repeat FontTextOut() for each line because I wanted my 64x64 sized grid to start at the left edge. In my tile engine (for NXT RPG) it needs to draw it just before the screen starts and stop just after the screen ends to properly show animation. Again I had to repeat FontTextOut() for each line since DRAW_OPT_FONT_WRAP is fixed on screens right edge.

[quote=muntoo]This is something that should be fixed - it limits our memory use significantly. Could you generate NBC code which reinitializes the arrays only in scope of the block at the end of the block?[/quote]Could this be enabled/disabled with a keyword? Sometimes performance is more important than memory usage.
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: wishlist for NXC

Post by muntoo »

spillerrec wrote:Could this be enabled/disabled with a keyword? Sometimes performance is more important than memory usage.
That's what static is for. (I asked for that a little while ago.)
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 15 guests