ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

Getting Into a Routine


Circuit Cellar Online
THE MAGAZINE FOR COMPUTER APPLICATIONS
Circuit Cellar Online offers articles illustrating creative solutions
and unique applications through complete projects, practical
tutorials, and useful design techniques.

GETTING INTO A ROUTINE

Lessons from the Trenches Setting Up an Integer Print Routine

by George Martin

Start ı Determining Whatıs Needed ı A Definition ı For Arguments Sake ı The Code ı Sources and PDF

FOR ARGUMENT'S SAKE

For the different types of arguments except floating point types, the math involved to accomplish the formatting is simple and straightforward. But, the floating point requirements of the printf routines require that the floating point math routines be linked into the code. Therefore, using the built-in formatted print routines will expand the code by pulling in floating point routines, even if you never specify a floating point variable or format.

On one recent project, the code expanded by 4 KB when I used sprintf. If you need floating point operations in your embedded project, then most of the overhead is already there. But if you donıt need floating point and want to use printf, then youıre stuck with this code expansion. The worst part is that itıs code youıll never use.

The solution? I came across a neat download from Mr. Rud Merriman. Itıs dated 1991 and first appeared in Embedded Systems Programming. The code is a reduced version of printf, one with all the floating point options removed. This code supports the l, d, x, s, and c format types along with some special characters like \n and \r. But, the great part is that you can see Merrimanıs approach to formatted printing and tailor these routines to your particular situation.

PREVIOUS NEXT


Circuit Cellar provides up-to-date information for engineers. Visit www.circuitcellar.com for more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com or subscribe online. ıCircuit Cellar, the Magazine for Computer Applications. Posted with permission.
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ