wishlist for NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: wishlist for NXC

Post by afanofosc »

I don't think FormatNum actually works with strings. The compiler must be generating bad code or something. The opcode that I added to the enhanced firmware definitely should not do the right thing if you pass in an array instead of a scalar as the third parameter (iirc).

fmtnum ar_out, fmt_in, value

Here's the firmware code:

Code: Select all

        //Make sure we're trying to convert a scalar/float to a string
        if (TypeCode3 == TC_VOID || (TypeCode3 > TC_LAST_INT_SCALAR && TypeCode3 != TC_FLOAT)) {
          Status = ERR_INSTR;
          return (Status);
        }
This suggests to me that it is not passing your string into the fmtnum opcode in the NBC code generated by the NXC layer since it would return an ERR_INSTR status value if it did.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

hm, it appears to work correctly although it seems to work (and should work) coincidently faulty -
a real Wunderhorn, this Lego firmware :roll:
dsjove
Posts: 56
Joined: 22 Jan 2011, 23:22

Re: wishlist for NXC

Post by dsjove »

We cannot pass an array member as a reference. The work around is to use the array index as the reference variable. Is it possible to resolve the array access as a reference?

Code: Select all

struct Something
{
	int v1;
	int v2;
};

void DoSomethingWith(Something& Else)
{
}

Something everything[4];

task main()
{
	Something today;
	for (int i = 0; i < 4; i++)
	{
		DoSomethingWith(everything[i] /*today*/);
	}
}
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

I indeed just got repetitive runtime errors (File error -1) using printf with "%s" and variable strings.

so my wish is:
a real correct working printf function like in ANSI C stdio.h

that means:
- working with both nums and strings
- working with multiple format strings and multiple variables
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: wishlist for NXC

Post by muntoo »

Can we have "real" pass-by-referencing? I recall that you [John] once said something like this:
Guess who wrote: There is no real passing by reference, so there should be no speed improvement between

Code: Select all

#define LOL void foo(int &bar[])
and

Code: Select all

#define LOL void foo(int bar[])
in

Code: Select all

LOL
{

}

int myarr[1000];
foo(myarr);
in terms of speed.
I think this shouldn't be too hard to implement [using NBC global variable magic card tricks], and it'd help speed in some of my programs. (I may be wrong.)
Image

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


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: wishlist for NXC

Post by afanofosc »

For inline functions it might not be too hard to replace reference parameters with whatever you pass in using some kind of NBC magic but a non-line function that is called at run-time in more than one place with different input arguments could not be magically "fixed" by the compiler at compile time. A real reference type requires real firmware VM support for pointers, which does not exist currently - and without a lot of work on the enhanced NBC/NXC firmware probably will never exist.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: wishlist for NXC

Post by mattallen37 »

I want support in the enhanced FW and API functions, for the "Absolute position reglation in firmware" feature that Nicolas created.

It is an awesome feature, and exactly what I have been wanting for a long time, but the FW isn't based on the "normal" enhanced FW. Now I can finally have a "rack and pinion" type car, and have it automatically steer to the right position ;) .
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 »

me too! :)
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: wishlist for NXC

Post by afanofosc »

I will work to incorporate the new absolute position regulation changes from Nicolas into my enhanced NBC/NXC firmware. I am also working on getting my firmware SVN repository up on sourceforge. Hopefully I can get it up there this month.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

John, what do you think about "outsourcing" some libs in order to decrease the memory NXC needs?
e.g., I dont regularily need graphic libraries (except fonts).
My suggestion would be to resurrect #include for specific libraries -
nxtdefs.h may be included automatically (or- maybe not) -
and anyone who wants different fonts may
#include "fonts.h"
who wants advanced graphics:
#include "graphics.h"
and maybe who ever (I actually can't imagine who exactly) likes faked stdio functions may use
#include "fakedio.h" Image

ok-
the last one admittedly was a joke (because this lib's size would extend even the nxtdefs.h) -
no, I'm kidding -
but honestly, I think the rest might be a good idea... :)
Post Reply

Who is online

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