The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: seymour_glass on April 27, 2006, 04:03:31 AM

Title: Character Translation.......
Post by: seymour_glass on April 27, 2006, 04:03:31 AM
I sure hope you guys know what i mean.  When trying to write a translation of a table using xlat, how do i write over control characters?  Rather how do i NOT write over a control character?  Specifically, I am trying to change only the lowercase letters to uppercase....so that all letters would be uppercase after the translation is done.
Title: Re: Character Translation.......
Post by: Ratch on April 27, 2006, 05:25:07 AM
seymour_glass,

     Assuming you are referring to ASCII characters, all 26 lower case characters are between 061H to 07AH inclusive.  Forget about XLAT, just check whether the character is within the range before you change it.  Notice that the difference between a upper and lower case is one constant bit.  Makes it easy to change. Ratch
Title: Re: Character Translation.......
Post by: hutch-- on April 27, 2006, 05:25:11 AM
seymour,

XLATB may not be the best way to do what you are after, if you only want to change the lower case characters, it can probably be done cleaner and easier another way. You only have to test the upper and lower limit of the lower case ascii ange to do tis.

XLATB is basically designed for character set conversions although it can be used for other tasks.
Title: Re: Character Translation.......
Post by: seymour_glass on April 27, 2006, 06:54:41 AM
Ya, i figure there would be an easier way.  However, it is part of an assignment, not efficient, but only aimed at teaching character translations i guess...it is for a conversion table, though,  converting only(for the purpose of this exercise) the lower case....i think my question is actually the point of the exercise....assuming i must use xlat....

so assuming that i am taking about the ascii characters, and that it must be done using xlat...how do i either write the control characters (cr, Lf..etc..) over themselves or to leave them alone completely while being able to change the letters?
Title: Re: Character Translation.......
Post by: hutch-- on April 27, 2006, 08:42:16 AM
Basically specify a range on the return from XLATB and chose whether you do the replacement or not.
Title: Re: Character Translation.......
Post by: Roger on April 27, 2006, 02:35:16 PM
Seymour,

The easiest way to do it using XLAT is to put the control character values into thier positions in the XLAT table so that they are 'translated' into themselves i.e. not changed.

Regards Roger
Title: Re: Character Translation.......
Post by: seymour_glass on April 27, 2006, 07:12:27 PM
well that is my question.  how do i put them into their places without changing them.....

ok heres an example of the translation table i am basing mine off of...

table       BYTE   48 DUP (' '), '0123456789', 7 DUP (' ')
              BYTE   'abcdefghijklmnopqrstuvwxyz', 6 DUP (' ')
              BYTE   'abcdefghijklmnopqrstuvwxyz', 133 DUP (' ')

however, in this case they are changing uppercase to lowercase...what i want to do is rather than write blanks over the control characters, i want to keep them.  My contention is that, for example, the first ascii code is 00, or NUL. if i was to use either the '00' or the 'nul' i would write over the space for the second ascii code SOH, correct? 
Title: Re: Character Translation.......
Post by: Roger on April 27, 2006, 08:27:25 PM
Seymour,

The clue is in the word BYTE this tells the assembler/compiler that you want data that is 8bits or 2 hex characters long. in your table you have put everything in quotes '  '  . This tells the assembler to use the 8 bit ascii code for each character in the string.  If you put the control characters in without quotes the asembler puts them in as they are.

table BYTE   00h,01h,02h,03h,04h,05h,06h,07h,08h,09h,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh
        BYTE   010h,011h,012h,....etc. etc.

REgards Roger
Title: Re: Character Translation.......
Post by: seymour_glass on April 27, 2006, 08:46:29 PM
ooooooook, that makes sense.  Sry..didn't occur it was the  ' ' that allowed me to only use the letters and numbers consecutively like i did...thanks much...

seymour