SX/B routine to convert WORD value to ASCII
![Bean](https://forums.parallax.com/uploads/userpics/855/n505WZVEIPHT1.jpg)
I was working on a STR routine that converts a word value to ASCII for inclusion in the SX/B compiler.
Here is what I came up with. The routine had to be small and relatively fast, I think this one fits the bill nicely.
You specify an array address that will hold the ascii characters, then a word variable, then a character to use for leading zeros (most often a space or a zero).
There has been other routines posted to do this, but I think this one is more flexible (by allowing user specified leading zero character), smaller and faster.
Let me know what you think.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
Here is what I came up with. The routine had to be small and relatively fast, I think this one fits the bill nicely.
You specify an array address that will hold the ascii characters, then a word variable, then a character to use for leading zeros (most often a space or a zero).
There has been other routines posted to do this, but I think this one is more flexible (by allowing user specified leading zero character), smaller and faster.
Let me know what you think.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
Comments
-Dan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A saint-like quantity of patience is a help, if this is unavailable, a salty vocabulary works nearly as well." - A. S. Weaver
· It is in assembly ??? What do you mean by "cleaned up" ???
· SX/B will automatically load __PARAM1 with the address of the array, __PARAM2 will hold the LSB of the word variable, __PARAM3 will hold the MSB of the word variable, and __PARAM4 will hold the leading zero character.
· Note that __PARAM1 thru __PARAM5 must be in the global area (as is always the case in SX/B).
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
This is excellent! A friend of mine is waiting on his SX development kit and one of the first programs he was going to work on needs to use a routine like this. I'm going to help him get started with the SX chips and this routine will certainly save some time.
Does this mean you're getting another release of SX/B ready? If so i'd be willing to test it. I've also got some notes about the SX48 timers which could help a lot if added to the help file for SX/B.
Best Regards,
Robert
(I've been a little busy testing a SX-Key debug issue [noparse];)[/noparse]
-Dan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A saint-like quantity of patience is a help, if this is unavailable, a salty vocabulary works nearly as well." - A. S. Weaver