View Single Post
Old 05-16-2008, 04:59 PM   #70 (permalink)
awillard69
EcoModding Apprentice
 
awillard69's Avatar
 
Join Date: Feb 2008
Location: Streamwood, IL
Posts: 105

Dakota - '00 Dodge Dakota Club Cab, Sport
90 day: 18.57 mpg (US)

Jeep - '01 Jeep Wrangler TJ Sport
90 day: 18.46 mpg (US)
Thanks: 0
Thanked 1 Time in 1 Post
Thumbs up

Quote:
Originally Posted by dcb View Post
So how do I have 64 bit math on the arduino without the 7k libraries. I can't declare one long long without running out of space. But need to do some accurate multiplying/dividing that would benefit from the extra bits. Does anyone know of any short and sweet 64 bit math routines handy that take less than 7000 bytes?
I couldn't wait for my board to get assembled, so I started playing with the latest code here at work.

I was able to shrink the sketch size from 7464 bytes to 6642 bytes (11% reduction) by just adjusting the data types used. For instance where you have
Code:
for( int x = 0; x < 10; x++ )
You can save space by converting it to
Code:
for( byte x = 0; x < 10; x++ )
It can be anywhere from 1 to 3 bytes, depending on system. Note: I cannot verify that any changes do not negatively impact the operation of the code itself.

Just changing the various loop control variables from "int" to "byte", I was able to reduce the size quite a bit.

Nextly, removing variables from the global scope has an even greater impact.

For instance, moving
Code:
int vsspinstate=0;
into the function where it is used saves 40 bytes! I think that maybe you planned to use it elsewhere, but are not currently. If you don't intend to use it, trim it completely and save the space altogether.

Now that I look deeper into the code, not that I understand everything you build so far, you are using some OO constructs (LCD and trip classes). You may also be adding overhead you don't expect and may gain some significant space by converting to structures and functions. Anecdotal perspective: there is no OO/C++ in the Linux kernel (per Linus) because of the overhead in complexity, size and speed - performance is critical. OO is for the programmer, not the processor/CPU.

Let me know if you want to see my modifications. Since you are up and running, you may be able to evaluate their "properness" better than I can at this point.

It's nice to be more than the sum of our individual parts - together we are stronger.
__________________

  Reply With Quote