> -----Original Message----- > From: Martijn van Aartrijk [SMTP:martijn@ROBOSAIL.COM] > Sent: Thursday, June 05, 2003 1:11 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]: How to optimize? > > Hello all, > > I have this irritanting calculation which I must do on my PIC16F877, and > I'm using CCS PIC C (PCM). Trouble is, this calculation alone takes up > 4% of my code space, and I want it reduced. Unfortunately, my PIC asm > isn't too good and I don't really know where to begin. I was hoping some > of you might be able to help. > > The calculation includes a few calibration values (end on -Cal) and have > to do with some timing intervals. > > y = (T1 - ((ZCal * T2) / T2Cal) / T2Cal; > > In itself, no real shocking formula. Point is, T1, ZCal, T2 and T2Cal > are unsigned longs (int16), so their product is an int32. Result y is a > float. As you can see, the compiler generates an incredible lot of code > to handle all the int32, int16 and float stuff. So my question is: does > anyone know how to handle this more efficiently? I've been trying to > rewrite the equation but it doesn't seem to get any better. > > Thanks a lot! > Martijn > > PS. Yes, this is a repost, but I'm still stuck with the problem. Sorry. > Do you really require the answer to be a float? Have a look at the recent thread on fixed point calculations (subject: Tips to reduce Program Size using CCS C) Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu