Page 1 of 1

upper case to lower case

PostPosted: Mon Oct 15, 2012 4:20 pm
by blackswan
Hi all,

Is there any instruction to change a string of upper case into lower case.

How can we toggle the strings.

please help

regards

Re: upper case to lower case

PostPosted: Mon Oct 15, 2012 4:24 pm
by BillyBoyo
You want to do it in Assembler?

Re: upper case to lower case

PostPosted: Mon Oct 15, 2012 4:27 pm
by blackswan
Hi Billy

Yes. Can it be possible?

Re: upper case to lower case

PostPosted: Mon Oct 15, 2012 4:39 pm
by BillyBoyo
Yes, it can be done. Since any high-level language has to come down to the machine instructions, you can do anything that is possible in another language. Just might (not always) take you writing more instructions. I was just checking you really wanted Assembler.

Have you googled a bit? There really are many ways you could go about it. How about having a piece of storage defining all the upper-case letters, a piece of storage defining all the lower-case letters. Find each source character in the appropriate piece of storage, and use that displacement to get it from the "converted value" piece of storage.

Also, have a look at the hex values of upper-case and lower-case letters.

You can think about these things. Work up a couple of things, discovering what else you need to keep in mind.

Something may hit you while you're going along, depending on the sort of stuff you've coded before.

Re: upper case to lower case

PostPosted: Tue Oct 16, 2012 8:37 am
by dick scherrer
Hello,

Do consider that maybe only Some of the case should be "flipped".

Re: upper case to lower case

PostPosted: Tue Oct 16, 2012 10:32 am
by steve-myers
There's always the translate instruction -
         TR    STRING,TABLE
         ...
STRING   DC    C'UPPER CASE CHARACTERS'
TABLE    DC    0XL256'0',(C'A')AL1(*-TABLE),9AL1(*-TABLE-X'40')
         DC    (C'J'-(*-TABLE))AL1(*-TABLE),9AL1(*-TABLE-X'40')
         DC    (C'S'-(*-TABLE))AL1(*-TABLE),8AL1(*-TABLE-X'40')
         DC    (256-(*-TABLE))AL1(*-TABLE)
The code to generate the TABLE are will not work with the Assist Assembler, but it will work with the IBM Assemblers. Obviously it is tailored to EBCDIC; a table to perform something equivalent for ASCII would be different

(C'A')AL1(*-TABLE) generates bytes to translate characters from X'00' to X'C0' to themselves.
9AL1(*-TABLE-X'40') generates bytes to translate A through I to a through i. The remainder of the table you can figure out for yourself.

The classic code to translate EBCDIC lower case characters to upper case is OC STRING,=256X'40'. This code does not alter the punctuation characters, upper case characters, and numeric characters. Why is an exercise for you. My first thought was something like NC STRING,=256AL1(255-X'40') rather than the TR, but I realized it would disturb the punctuation characters, and the numbers. Oops.

Re: upper case to lower case

PostPosted: Tue Oct 16, 2012 11:04 am
by blackswan
Hi Billy, Hi Steve, Hi sherrer,

Thanks... I think i need to try again in my own.,.. then if i will face any prob i can show you all with the program...

@steve: thanks for example

Re: upper case to lower case

PostPosted: Tue Oct 16, 2012 8:12 pm
by dick scherrer
You're welcome - someone will be here when there are questions :)

d