| ??? 03/19/02 20:44 Read: times |
#20982 - RE: binary to ascii string, Guy |
"a counter can hold a maximum of 65535, so divide by 10 to get the ones..."
The thread in question didn't provide assembly language source code but the logic was explained sufficiently that the code should be pretty easy to develop. 1. Take current value and divide by 10. 2. Shift current ASCII answer "right" one character and add remainder as the next significant character. 3. Was the dividend 0? If not, go back to step 1. 4. You're done. For example, as was mentioned in the previous thread, consider the number 65535: 1. 65535/10 = 6553 remainder 5. ASCII="5" 2. 6553/10 = 655 remainder 3. ASCII="35" 3. 655/10 = 65 remainder 5. ASCII = "535" 4. 65/10 = 6 remainder 5. ASCII = "5535" 5. 6/10 = 0 remainder 6. ASCII = "65535" 6. You're done! In the above process the only challenge really is doing 16-bit division by 10 and there are some math routines in the Code Library that will do that for you. I would think the above would have to be more efficient than using BCD as some intermediate expression. No reason to go to BCD if you can go directly to ASCII. Good luck, Craig Steiner |
| Topic | Author | Date |
| want to convert from binary to ascii str | 01/01/70 00:00 | |
| RE: want to convert from binary to ascii str | 01/01/70 00:00 | |
| RE: want to convert from binary to ascii str | 01/01/70 00:00 | |
| RE: want to convert from binary to ascii str | 01/01/70 00:00 | |
| RE: want to convert from binary to ascii str | 01/01/70 00:00 | |
| RE: want to convert from binary to ascii str | 01/01/70 00:00 | |
| RE: want to convert from binary to ascii str | 01/01/70 00:00 | |
| RE: want to convert from binary to ascii str | 01/01/70 00:00 | |
| RE: want to convert from binary to ascii str | 01/01/70 00:00 | |
| RE: want to convert from binary to ascii str | 01/01/70 00:00 | |
| RE: binary to ascii string, Guy | 01/01/70 00:00 | |
| RE: binary to ascii string, Guy | 01/01/70 00:00 | |
| RE: binary to ascii string, Guy | 01/01/70 00:00 | |
| RE: binary to ascii string, Guy | 01/01/70 00:00 | |
| RE: want to convert from binary to ascii str | 01/01/70 00:00 | |
RE: binary to ascii string, Guy | 01/01/70 00:00 |



