AW: Converson of hex value to character

2016-09-14 Thread bernd.oppol...@t-online.de
Thank you very much ... 

BTW: I'm doing ASSEMBLER classes and training in Germany since 1985
for large companies of the financial sector, but in the last years there was 
not 
much need for this. But there should be, IMO, because there are still many 
ASSEMBLER programs running, and the maintenance (and migration, maybe) 
cannot all be done by us oldtimers - I'm only 57 :-) ... recently I was called 
for a mainframe project here in Germany, and I was the youngest candidate !!
The ages spanned from 57 to 73. 

and so we should try to teach ASSEMBLER etc. to young people, too. 

So: if you plan a project to teach ASSEMBLER to some younger people 
in your company somewhere in Europe, please call me; I would like 
to support you doing this. 

At the moment I'm working at a project in the financial area, which uses 
C and PL/1 (and DB2), but doing an ASSEMBLER teaching project 
in between should not be a problem at all. 

Kind regards

Bernd



-Original-Nachricht-
Betreff: Re: Converson of hex value to character
Datum: 2016-09-13T14:41:52+0200
Von: "Steve Smith" 
An: "IBM-MAIN@LISTSERV.UA.EDU" 

Bernd Oppolzer's answer is the best, 
...

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-13 Thread Bill Ashton
Thank you for all these great suggestions. My needs are very simple in only
having to translate two different 1-byte fields, so Bernd's solution worked
out to be the easiest and quickest to use.

I will be saving these other ones, and like the macro idea as well as a
quick print using DFSORT (Thanks Kolusu!). If I get some time one day, I
will play with these other options to make sure I know how to use them when
it is necessary.

Thanks again!
Billy

On Tue, Sep 13, 2016 at 8:41 AM, Steve Smith  wrote:

> Bernd Oppolzer's answer is the best, although I'd prefer to define the
> fields so length overrides weren't needed:
> ONEBYTE DS XL2
> TWOBYTE DS CL3
>
> Not that I'd likely use it for small fields, but the TROT instruction is
> great at this.  It requires a 512-byte translate table though:
>
> TROTTAB DC C'000102030405060708090A0B0C0D0E0F'
>DC C'101112...
> ...
>
> Rob Scott posted this with more detail on the Assembler List a while back.
>
> sas
>
> On Tue, Sep 13, 2016 at 7:55 AM, don isenstadt 
> wrote:
>
> > I was interested in seeing a complete example.. here is one..
> > http://www.z390.org/contest/p3/P3MM1.TXT
> >
> > --
> > For IBM-MAIN subscribe / signoff / archive access instructions,
> > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
> >
>
>
>
> --
> sas
>
> --
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>



-- 
Thank you and best regards,
*Billy Ashton*

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-13 Thread Steve Smith
Bernd Oppolzer's answer is the best, although I'd prefer to define the
fields so length overrides weren't needed:
ONEBYTE DS XL2
TWOBYTE DS CL3

Not that I'd likely use it for small fields, but the TROT instruction is
great at this.  It requires a 512-byte translate table though:

TROTTAB DC C'000102030405060708090A0B0C0D0E0F'
   DC C'101112...
...

Rob Scott posted this with more detail on the Assembler List a while back.

sas

On Tue, Sep 13, 2016 at 7:55 AM, don isenstadt 
wrote:

> I was interested in seeing a complete example.. here is one..
> http://www.z390.org/contest/p3/P3MM1.TXT
>
> --
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>



-- 
sas

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-13 Thread don isenstadt
I was interested in seeing a complete example.. here is one..
http://www.z390.org/contest/p3/P3MM1.TXT

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-12 Thread Campbell Jay
Have a MACRO laying around here...

 MACRO 
&LABEL   HX2CH &FLD,®   
.* CONVERTS THE HEX FIELD IN '&FLD' WHOSE LENGTH   
.* IS IN REGISTER '®' TO CHARACTER INTO '&FLD'  
.* '&FLD' MUST BE BIG ENOUGH TO HOLD THE CHARACTER VERSION OF THE  
.* HEX NUMBER THAT IS BEING CONVERTED (I.E. TWICE THE LENGTH IN '®')
AIF   (® GT 1 AND ® LT 15).OK 
  
MNOTE 12,'USE ONLY REGS 2 TO 14 FOR SECOND OPERAND' 
  
MEXIT   
  
.OKANOP  
&LABEL LR1,®  R1 = LENGTH OF HEX FIELD
   BCTR  1,0 ADJUST TO USE AS INDEX 
 
   LA15,&FLD.(1) R15 -> LAST BYTE OF HEX FLD
 
  AR1,1 DOUBLE TO INDEX CHAR FIELD  
  LA1,&FLD.(1)  R1 -> LAST 2 BYTES OF CHAR FLD  
  LR0,®  R0 = # OF HEX BYTES TO BE CONVERTED 
A&SYSNDX MVC   1(1,1),0(15)
   UNPK  0(1,1),0(1,15) 
 
   NI0(1),X'0F' 
   NI1(1),X'0F' 
  BCTR  15,0   
  BCTR  1,0
  BCTR  1,0
 BCT   0,A&SYSNDX 
 LR15,®
 AR15,15  
 BCTR  15,0   
 EX15,B&SYSNDX
 B C&SYSNDX+16
B&SYSNDX TR&FLD.(0),C&SYSNDX  
C&SYSNDX DCC'0123456789ABCDEF'
  MEND 

Jay Campbell
IBM OS Support Section

-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@listserv.ua.edu] On Behalf 
Of Randy Hudson
Sent: Monday, September 12, 2016 12:59 PM
To: IBM-MAIN@listserv.ua.edu
Subject: Re: Converson of hex value to character

In article ,
Billy Ashton wrote:

> How do I take a 1-byte character field containing a Hex value like x'C4'
> and turn it into a 2-byte character field containing C4 (x'C3F4')? I 
> know how to turn it into a decimal value and Edit and all that, but I 
> am blanking on this simple conversion.

One way is with three TR instructions, and some MVC instructions.  One TR 
instruction translates each character into the EBCDIC representation of the 
first half, one TR instruction converts each to the EBCDIC representation of 
the second half, and one interleaves them.  Up to 128 bytes of input can be 
handled per pass through this sequence.

Another way uses the UNPK command (from a source which includes a dummy byte in 
the next byte of storage) followed by a single TR instruction.  That uses less 
storage but is limited to 7 bytes of input per pass.

--
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-12 Thread Randy Hudson
In article ,
Billy Ashton wrote:

> How do I take a 1-byte character field containing a Hex value like x'C4'
> and turn it into a 2-byte character field containing C4 (x'C3F4')? I know
> how to turn it into a decimal value and Edit and all that, but I am
> blanking on this simple conversion.

One way is with three TR instructions, and some MVC instructions.  One TR
instruction translates each character into the EBCDIC representation of the
first half, one TR instruction converts each to the EBCDIC representation of
the second half, and one interleaves them.  Up to 128 bytes of input can be
handled per pass through this sequence.

Another way uses the UNPK command (from a source which includes a dummy byte
in the next byte of storage) followed by a single TR instruction.  That uses
less storage but is limited to 7 bytes of input per pass.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-12 Thread Dan Skomsky
This is easy peasy.  The following was gleaned for subroutine HEXO written 
circa 1969 at Penn State.  Take with it what you will.  This subroutine 
converts the entire contents of a GP Register to an eight byte printable buffer.
.
.
.
 L1,  REG TO BE CONVERTED   
   
 ST 1,XXHOAREA  STORE NUMBER TO BE CONVERTED
 LR 1,0 R1 POINTS TO OUTPUT AREA
 L14,=A(XXHOTAB3-C'0')FOR CONVERSION OF 0-9 TO F0-F9   
 UNPK  XXHODOUB(9),XXHOAREA(5) CONVERT THE NUMBER  
 TR XXHODOUB,0(14)  MAKE PRINTABLE  
 MVC 0(8,1),XXHODOUB MOVE NUMBER TO CALLER   
.
.
.  
XXHOTAB3   DCC'0123456789ABCDEF'  
XXHOAREA   DSF,C STORAGE AREA 
XXHODOUB  DSD,C STORAGE AREA 
--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-12 Thread Richard Rogers
IC   Rx,HEXVAL
STC  Rx,DISPLY+1
SRL  Rx,4
STC  Rx,DISPLY
NC   DISPLY(2),=X'0F0F'
TR   DISPLY(2),=C'0123456789ABCDEF'

-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
Behalf Of Bill Ashton
Sent: Monday, September 12, 2016 09:33
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Converson of hex value to character

Hello my friends, this is a simple assembler question, but for some reason
is not clicking for me this morning.

How do I take a 1-byte character field containing a Hex value like x'C4'
and turn it into a 2-byte character field containing C4 (x'C3F4')? I know
how to turn it into a decimal value and Edit and all that, but I am
blanking on this simple conversion.

Thanks for your patience and your solution!

-- 
Thank you and best regards,
*Billy Ashton*

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-12 Thread Tony Harminc
On 12 September 2016 at 11:52, Bernd Oppolzer
 wrote:
> You need two additional bytes after ONEBYTE and TWOBYTE,
> so that UNPK can do its nibble switching thing there.

If you have many bytes to convert (say, more than 7), the TROT
(TRanslate One to Two) instruction with a 512 byte table can do it all
in one step with effectively unlimited length. Whether this is faster
than a loop of UNPKs and TR fixups (of course you need only one TR for
up to 256 bytes), I don't know. Certainly it's conceptually easy to
understand.

A warning, though. The fine print in the instruction description says
"The translation table is *treated as being* on a double-word
boundary" [my emphasis]. This means TROT silently ignores the
rightmost 3 bits of the table address, so make sure you actually put
it on a doubleword boundary. HLASM cannot warn about this, because the
address is in a register. (Ask me how I know about this problem...)

Tony H.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-12 Thread Richard Rogers
IC   Rx,HEXVAL
STC  Rx,DISPLY+1
SRL  Rx,DISPLY
NC   DISPLY(2),=X'0F0F'
TR   DISPLY(2),=C'0123456789ABCDEF'

-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
Behalf Of Bill Ashton
Sent: Monday, September 12, 2016 09:33
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Converson of hex value to character

Hello my friends, this is a simple assembler question, but for some reason
is not clicking for me this morning.

How do I take a 1-byte character field containing a Hex value like x'C4'
and turn it into a 2-byte character field containing C4 (x'C3F4')? I know
how to turn it into a decimal value and Edit and all that, but I am
blanking on this simple conversion.

Thanks for your patience and your solution!

-- 
Thank you and best regards,
*Billy Ashton*

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-12 Thread Bernd Oppolzer

I forgot to mention:

performs better, if you do it not for one byte, but for 4 bytes at once,
with longer length specifictions on UNPK (this is what I do all the time,
when I convert fullwords or register content to hex).

UNPK NINE(9),FIVE(5)

Kind regards

Bernd


Am 12.09.2016 um 17:52 schrieb Bernd Oppolzer:

You need two additional bytes after ONEBYTE and TWOBYTE,
so that UNPK can do its nibble switching thing there.

ONEBYTE  DCX'C4'
 DSC
TWOBYTE  DSCL2
 DSC
...
 UNPK  TWOBYTE(3),ONEBYTE(2)
 TRTWOBYTE,HEXTAB-C'0'
...
HEXTAB   DCC'0123456789ABCDEF'

I hope, I didn't miss anything.

Kind regards

Bernd


Am 12.09.2016 um 17:33 schrieb Bill Ashton:

Hello my friends, this is a simple assembler question, but for some 
reason

is not clicking for me this morning.

How do I take a 1-byte character field containing a Hex value like x'C4'
and turn it into a 2-byte character field containing C4 (x'C3F4')? I 
know

how to turn it into a decimal value and Edit and all that, but I am
blanking on this simple conversion.

Thanks for your patience and your solution!





--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-12 Thread Paul Gilmartin
On 2016-09-12, at 09:33, Bill Ashton wrote:
> 
> How do I take a 1-byte character field containing a Hex value like x'C4'
> and turn it into a 2-byte character field containing C4 (x'C3F4')? I know
> how to turn it into a decimal value and Edit and all that, but I am
> blanking on this simple conversion.
>  
Unpack; Translate.

May need to pad a byte on the right so Unpack doesn't mess with the sign.

-- gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Converson of hex value to character

2016-09-12 Thread Bernd Oppolzer

You need two additional bytes after ONEBYTE and TWOBYTE,
so that UNPK can do its nibble switching thing there.

ONEBYTE  DCX'C4'
 DSC
TWOBYTE  DSCL2
 DSC
...
 UNPK  TWOBYTE(3),ONEBYTE(2)
 TRTWOBYTE,HEXTAB-C'0'
...
HEXTAB   DCC'0123456789ABCDEF'

I hope, I didn't miss anything.

Kind regards

Bernd


Am 12.09.2016 um 17:33 schrieb Bill Ashton:


Hello my friends, this is a simple assembler question, but for some reason
is not clicking for me this morning.

How do I take a 1-byte character field containing a Hex value like x'C4'
and turn it into a 2-byte character field containing C4 (x'C3F4')? I know
how to turn it into a decimal value and Edit and all that, but I am
blanking on this simple conversion.

Thanks for your patience and your solution!



--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Converson of hex value to character

2016-09-12 Thread Bill Ashton
Hello my friends, this is a simple assembler question, but for some reason
is not clicking for me this morning.

How do I take a 1-byte character field containing a Hex value like x'C4'
and turn it into a 2-byte character field containing C4 (x'C3F4')? I know
how to turn it into a decimal value and Edit and all that, but I am
blanking on this simple conversion.

Thanks for your patience and your solution!

-- 
Thank you and best regards,
*Billy Ashton*

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN