Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Can anybody describe an algoritm to achieve conversion from a unsigned 8 bit binary number to a ASCII string. It will be implemented in assembly.
TIA.

There is no difference between the two. The only difference is in how a program chooses to perceive and represent the 8 bits read from a file or other input device. The binary data 00100000 is identical to the ASCII value 32 which is the space character. ASCII is also already an unsigned 8 bit integer. In fact, the term "unsigned 8 bit integer" isn't even a form of data but rather a way or representing data. I could also view the same data as a signed 8 bit integer if I had need to. I could also choose to represent this as a hex value and it would still be the exact same data. The information needs no conversion but simply needs to be represented as your program needs it to be. This, however, does not require filters or conversions but rather a segment of code that will represent the value in the manner you wish. I hope this helps clarify things for you.
borelli34

Now if you meant converting an 8 bit unsigned number into either two ASCII characters that represent their Hex value, or an ASCII numeric string representing their base 10 value, that is a slightly different question and something that many versions of Assembly code exists for. Done a more than a few of these routines myself.

Paul, borelli34 is quite correct.
The only additional thing I would mention is that in passing your value to a print routine (say - int10,A or int10,13) you should check to see that it is within the range of 'printable' chars you wish to support, i.e. somewhere between 20h
and 7Fh, usually.If you're in text-mode, then the system BIOS will have bitmaps and a lookup table in place to display the associated bitmap to the screen. You can even change the text-mode bitmaps the BIOS loads!
If you're coding for a game, you can roll your (graph mode) charset from bitmaps you produce yourself, provide your own lookups, and blit to the screen as needed.
In either case, the idea's the same: the (ASCII) value you specify simply relates to the address of an actual bitmap (via an ASCII complient lookup table/indexed array) that gets printed to the screen.
It's just a convention.
jorgen

![]() |
Yahoo Messenger: link on ...
|
3 Wire RS232 interface pr...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |