Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/12/05 05:01
Read: times


 
Msg Score: +2
 +1 Good Answer/Helpful
 +1 Informative
#97117 - ANY DATATYPE TO STRING/CHAR CONVERSION
I just found this feature in SDCC and thought i could share it eith u people.SDCC has a printf() function similar to standard C .But since SDCC does not know what output device to print it to,SDCC requires the definition of putchar() function for its printf() command.What SDCC does is to parse the incoming data (of whatever datatype) to printf into single characters and call the putchar function for each of these characters.For example

int e=128;
printf("%d",e);
will call putchar as follows
putchar('1');
putchar('2');
putchar('8');

thus the printf function can also be used to convert INT TO BCD by the use of the putchar function(though this is slow and occupies more space).

The uses of this are boundless.With some clever programming and use of switch() u can have multiple output devices LCD,EEPROM etc.By clever use of the putchar() function u can parse any data to bytes to store in the EEPROM.

List of 5 messages in thread
TopicAuthorDate
ANY DATATYPE TO STRING/CHAR CONVERSION            01/01/70 00:00      
   Thanks for that            01/01/70 00:00      
   printf() to multiple devices            01/01/70 00:00      
   Yep!            01/01/70 00:00      
   Here's one I prepared earlier...            01/01/70 00:00      

Back to Subject List