Suggestions on how to minimise code size

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
bluejets
Posts: 12
Joined: Fri Oct 12, 2012 1:10 pm

Suggestions on how to minimise code size

Post by bluejets »

Have almost completed my first project using Flowcode 5 student version however when I compile it says I have gone over the 4K limit.
This was some concern to me when I initially bought the program as I had no real indicaton of limitations.
This has since been rectified in an earlier post and thanks to the suggestions there.

Thought perhaps someone could suggest a better way of approaching the job and get down under the limit.
Presently it is 290 odd over.
Attachments
sept16.fcf
(25.74 KiB) Downloaded 243 times
sept16.txt
(555 Bytes) Downloaded 219 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Suggestions on how to minimise code size

Post by Benj »

Hello,

Would it be possible to do the calculation using integer maths. The Floating point library for PIC will be huge and is likely consuming a lot of your ROM space.

bluejets
Posts: 12
Joined: Fri Oct 12, 2012 1:10 pm

Re: Suggestions on how to minimise code size

Post by bluejets »

The reason I used the floating point was because of the following calculation......

Calculate_Degrees = BCD - (Delay_Time / Cycle_Time) * 360

Without using floating point values, It would always return BCD value only and I thought the floating point approach was the only way.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: Suggestions on how to minimise code size

Post by kersing »

You could reorganize the formula a bit:

Calculate_Degrees = BCD - ( Delay_Time * 360 ) / Cycle_Time

Use a Long for Delay_Time if the result of the multiplication exceeds 32768.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Post Reply