News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Character Translation.......

Started by seymour_glass, April 27, 2006, 04:03:31 AM

Previous topic - Next topic

seymour_glass

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.

Ratch

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

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

seymour_glass

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?

hutch--

Basically specify a range on the return from XLATB and chose whether you do the replacement or not.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Roger

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

seymour_glass

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? 

Roger

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

seymour_glass

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