[comp.lang.asm370] Collating sequence of Hex ...

WURZBACH@OSHKOSHW.BITNET ("William F. Wurzbach") (10/27/89)

        I'm currently working on a small assembler project, and am faced
with the following problem:


        Being passed a list of EBCDIC character representations of hexadecimal
addresses, I must sort them into collating sequence. Unfortunately, EBCDIC
A - F collates *before* 0 - 9, but in true hex, it collates *after*. Has
anyone written a small subroutine that can maybe check for the validity of
the passes arguments ( 0-9,A-F ), and use some form of TR, TRT, CLI, ...etc
to get them into a form that collates properly ? I just *know* this has been
done before, I just can't find any examples at the moment. I'm sure I can
cobble something together, but it may not be pretty. Any suggestions ?

        I am not currently subscribed to the list, so please send mail to me
directly. I will summarize the responses and post them to the list later.

        Thanks for any help you can offer.

=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
William Wurzbach, System Programmer  |      Fax :  (414) 424 - 0010
c/o Computer Services                |    Phone :  (414) 424 - 3018
University of Wisconsin - Oshkosh    |   Bitnet :  WURZBACH@OSHKOSHW
800 Algoma Blvd.                     | Internet :  WURZBACH@OSHKOSH.WISC.EDU
Oshkosh, Wisconsin  54901            |
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

SEB1525@ccfvx3.draper.COM ("Steve Bacher ", Batchman) (10/27/89)

You should be able to just TR the ABCDEF to X'FAFBFCFDFEFF', sort away,
and then translate back.  Shouldn't take more than 3 additional lines of
code (unless your lines are > 256).
					- Steve Bacher (Draper Lab)

michael@MAINE.MAINE.EDU (Michael Johnson) (10/27/89)

If you don't care what your result looks like, you can translate A-F, which
are X'C1'-X'C6' into X'FA'-X'FF'. This would cause them to be collated
properly and would also be a good step to use just prior to packing the hex
string if you are converting from "zoned hex" to binary.

An example code segment:

TRANSLAT DS   0H
         TR   HEXSTRNG(8),HEXPREP
         PACK PACKED(5),HEXSTRNG(9)
         MVC  BINARY(4),PACKED
         .
         .
         .
HEXPREP  DS   0XL256
         DC   256X'00'
         ORG  HEXPREP+X'a'
         DC   X'FAFBFCFDFEFF'
         ORG  HEXPREP+X'A'
         DC   X'FAFBFCFDFEFF'
         ORG  ,
PACKED   DS   CL8
BINARY   DS   F

This becomes a little trickier if your hex string can vary in length, but
that would merely necessitate the use of EXecute.

Michael Johnson                           "We are the Priests of the Temples
University of Maine System                 of Syrinx. Our great computers fill
Computing and Data Processing Services     the hallowed halls." - Neil Peart

michael@MAINE.MAINE.EDU (Michael Johnson) (10/27/89)

oops.. I just spotted a typo error in my previous posting. The lines that
read:

      ORG   HEXPREP+X'a'
      ORG   HEXPREP+X'A'

should have read:

      ORG   HEXPREP+C'a'
      ORG   HEXPREP+C'A'

Sorry about that.

Michael Johnson                           "We are the Priests of the Temples
University of Maine System                 of Syrinx. Our great computers fill
Computing and Data Processing Services     the hallowed halls." - Neil Peart