View Single Post
Old Mar 13th, 2008, 2:59 PM   #5
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 889
Rep Power: 4 lectricpharaoh will become famous soon enough
Re: Deleting chracters

Quote:
Originally Posted by Benoit
To convert an ASCII character to uppercase, simply subtract 32 (The difference between a and A on the ascii table).
You're making the assumption that the character is lowercase to begin with; you'll need to test for that. Also, though you qualified it by specifying ASCII, the OP didn't say that (though if he's writing x86 assembly, it's most likely the case).

Assuming that he's using ASCII, one way of doing it faster would be to populate a 256-byte table, point DS:(E)BX at this table, and use XLATB. This eliminates checks for range, so you can quickly map one character to another. If you want strict ASCII with no support for the so-called 'high ASCII', you can cut the table by half, and mask against 07Fh before the lookup; this'll save a whopping 128 bytes. Just loop through the string, doing a lookup for each byte until you hit the end. Presumably, your string is null-terminated, but if it's not, you'll have a length count that you can load into (E)CX before you start.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp
lectricpharaoh is offline   Reply With Quote