??? 09/02/04 18:02 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#76827 - RE: Student Question II Responding to: ???'s previous message |
Erik:
If a "letter" is in memory it IS in hex. Donald: No, the data is already ASCII. Stop confusing the poor student please! :) A bit of explanation: Data in memory is in form of a bunch of transistors with or without current flowing through them :P Now as you certainly know, these transistors are combined into consistent units of "bits" (containing a single 0/1 value), bits are grouped in "bytes" (1 byte is 8 bits) Now the content of the byte can be read in different context, and the microcontroller/program has no idea what the "context" is, just the programmer does. Just like the character "O" may be read as capital O, number zero, a circle mark in tic-tac-toe, one eye of a ^OuO^ smiley, an outline of a bit of empty space or whatever you wish to see in the "O", just the same way the 8 bits change meaning in the way you look at them, and there are several generally agreed upon meanings of them: - 8 separate bits denoting 8 separate yes/no facts. - a number from 0 to 255 written in binary. - a number from -128 to 127 writen in U2 binary - Identifier of an ASCII character. (I mean, you need some font etc for actual ASCII character, but you can select/recognize it uniquely by one byte) - a number between 0 and 99 in BCD. - a number between 0 and FF in HEX - 2 digits in BCD or HEX - Half of a 0-65535 number - 1/3 or an RGB color value data (amount of Red, Green or Blue to be used) - 1/3 of HSV color value (Hue, Saturation or Value) - Monochrome grayscale pixel brightness - 8 pixels of b/w or planar display. - an identifier of a key pressed. ...and many many more. You don't need to "convert" from ASCII to hex or back. If you load a byte with 4Fh it contains bits with electrical levels set conforming to the set: 01001111 - and nothing else. And now when you read these bits it's up to you to decide if they are facts that first, third and fourth student failed a test and remaining 5 passed, or if it's character "O" in ASCII or value 79 in decimal or 2 hex digits, a 4 and a F, or some greenish yellow if you use it as the hue value, or right to execute file for group and others and do everything for the owner if you use it as UNIX file permission, etc etc etc. The microcontroller has no way to differ between 4Fh being a hex or a greenish yellow, so you don't worry about converting it, just copy away the value and don't worry if it's ASCII or hex - there's no difference between them :) |
Topic | Author | Date |
*Student Question* | 01/01/70 00:00 | |
RE: *Student Question* | 01/01/70 00:00 | |
RE: *Student Question* | 01/01/70 00:00 | |
Getting Started | 01/01/70 00:00 | |
Here is the key | 01/01/70 00:00 | |
RE: Here is the key | 01/01/70 00:00 | |
Jumping the gun | 01/01/70 00:00 | |
RE: Jumping the gun | 01/01/70 00:00 | |
RE: Jumping the gun | 01/01/70 00:00 | |
RE: Still Jumping the gun | 01/01/70 00:00 | |
Stop | 01/01/70 00:00 | |
RE: Stop ;-)))) | 01/01/70 00:00 | |
Here you go: | 01/01/70 00:00 | |
Student Question II | 01/01/70 00:00 | |
RE: Student Question II | 01/01/70 00:00 | |
RE: Student Question II | 01/01/70 00:00 | |
RE: Student Question II | 01/01/70 00:00 | |
RE: *Student Question*![]() | 01/01/70 00:00 |