Computing.Net > Forums > Programming > Binary to ASCII algoritm

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Binary to ASCII algoritm

Reply to Message Icon

Name: paul
Date: August 17, 2003 at 05:49:12 Pacific
OS: n/a
CPU/Ram: n/a
Comment:

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.




Sponsored Link
Ads by Google

Response Number 1
Name: borelli34
Date: August 17, 2003 at 09:36:51 Pacific
Reply:

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



0

Response Number 2
Name: JackG
Date: August 17, 2003 at 11:57:29 Pacific
Reply:

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.


0

Response Number 3
Name: jorgen
Date: August 17, 2003 at 12:44:44 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Yahoo Messenger: link on ... 3 Wire RS232 interface pr...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Binary to ASCII algoritm

Binary to ASCII conv. in assembly www.computing.net/answers/programming/binary-to-ascii-conv-in-assembly/12420.html

Java need code: hex to Ascii www.computing.net/answers/programming/java-need-code-hex-to-ascii/3727.html

Binary codes www.computing.net/answers/programming/binary-codes/7101.html