Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Translate UPPER CASE to lower case

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 496
Location: The Universe

PostPosted: Mon Oct 19, 2015 9:33 am    Post subject: Translate UPPER CASE to lower case
Reply with quote

Just for my amusement I was reviewing some very old topics in Assembler language and came across this one. The "solution" is incorrect, because its author ignored something important: the solution damaged characters that are not upper case characters.

In EBCDIC, lower case characters are in the range X'81' to X'89'. X'91 to X'99', and X'A2 to X'A9'. The upper case characters are in the range X'C1' to X'C9', X'D1' to X'D9', and X'E2' to X'E9'. The classic solution in EBCDIC to translate lower case characters to upper case is to OR X'40' into the character, so lower case a, X'81' becomes X'C1', upper case A. This does not damage a blank (X'40') or the punctuation characters. The solution in the earlier article performed an AND of B'10111111'. This will convert A to a, but a blank will become X'00', and the punctuation characters will be hopelessly damaged.

The "correct" solution uses the TR instruction and a translate table -
Code:
         TR    STRING,TRTAB
         ...
TRTAB    DC    0XL256'0'
         DC    (C'A')AL1(*-TRTAB)
         DC    C'abcdefghi',(C'J'-(*-TRTAB))AL1(*-TRTAB)
         DC    C'jklmnopqr',(C'S'-(*-TRTAB))AL1(*-TRTAB)
         DC    C'stuvwxyz',(256-(*-TRTAB))AL1(*-TRTAB)
         ...
STRING   DC    C'THIS MESSAGE CONTAINS LOWER CASE CHARACTERS'
There are many ways to code this translate table. (C'A')AL1(*-TRTAB) inserts text to translate a character from X'00' to X'BF' to itself, which takes care of blank and the punctuation characters. The remainder of the table I leave to the reader to interpret. Many programmers might choose this -
Code:
TRTAB    DC    256AL1(*-TRTAB)
         ORG   TRTAB+C'A'
         DC    C'abcdefghi'
         ORG   TRTAB+C'J'
         DC    C'jklmnopqr'
         ORG   TRTAB+C'S'
         DC    c'stuvwxyz'
         ORG   ,
Back to top
View user's profile Send private message

View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts Summing on Mixed Case Literals Roy Ware SYNCSORT 3 Tue Jan 03, 2017 10:18 pm
No new posts Case insenstive in INCLUDE Condtion smileseenu DFSORT/ICETOOL 2 Mon Feb 15, 2016 8:42 pm
No new posts How steps execute in Job in case of a... richiewalia JCL & VSAM 4 Tue Jan 12, 2016 12:34 pm
No new posts Formatting Names Upper to Lower Exclu... shajeeth DFSORT/ICETOOL 13 Wed Dec 10, 2014 10:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us