Page 1 of 1

New Data Types

Posted: Fri Nov 18, 2011 2:54 pm
by dbasnett
It is my understanding that v5 will contain a single bit (boolean? T/F) data type. If that is true I can see how it will save memory, but I wonder if the code will be longer? In pseudo-code:

foo as byte - used for T/F

if foo then - how much code to test T/F
else
endif

foo as bit- used for T/F

if foo then - how much code to test T/F
else
endif


My question boils down to how many instructions does it take, in both cases, to check for true / false. If there isn't a difference, or checking a single bit is shorter, then the question is moot. If checking a single bit takes more instructions then a choice can be made based on requirements.

Re: New Data Types

Posted: Fri Nov 18, 2011 4:45 pm
by Steve
We've not done much testing for this, and it will heavily depend on the program itself, the compiler toolchain used and any optimisations present.

I did a quick test and had the following results for a very simple program for an 8-bit PICmicro using BoostC:

using bools:

Code: Select all

RAM available:368 bytes, used:36 bytes (9.8%), free:332 bytes (90.2%), 
Heap size:332 bytes, Heap max single alloc:110 bytes
ROM available:4096 words, used:82 words (2.1%), free:4014 words (97.9%)
using bytes:

Code: Select all

RAM available:368 bytes, used:37 bytes (10.1%), free:331 bytes (89.9%), 
Heap size:331 bytes, Heap max single alloc:110 bytes
ROM available:4096 words, used:81 words (2.0%), free:4015 words (98.0%)
So it looks like you are correct - you will save RAM. But this may be at the cost of ROM.

But including the BOOL type in Flowcode is not just about saving memory. The biggest benefit for me is that it makes the code tighter and better to read.

Re: New Data Types

Posted: Fri Nov 18, 2011 5:30 pm
by dbasnett
Using Bools - RAM used = 36 bytes ROM Used = 82 words

Using Bytes - RAM used = 37 bytes ROM Used = 81 words

Bool diff. RAM used = -1 bytes ROM Used = +1 words

That is good information. We can certainly make an informed choice based on the requirement.

If I need to save RAM, use bool. If I need to save ROM, use byte. (in both cases there is an assumption that the other is not an issue)

If neither is of concern then bool is the logical ;) choice.

I can hardly wait for the release!

Re: New Data Types

Posted: Tue Nov 22, 2011 4:02 am
by saschech@gmx.de
Hello Team

Work`s "dbasnett" with the V5 beta?

Regards Wolfgang

Re: New Data Types

Posted: Tue Nov 22, 2011 9:30 am
by Steve
No - the figures were from an internal test.

We have had an advanced BETA now for a few weeks, but we are yet to distribute it widely.