[comp.lang.asm370] Register Display

conwell@rd1632.Dayton.NCR.COM (Ted Conwell) (04/10/90)

In article <ASM370%90033009415253@UCF1VM.BITNET> IBM 370 Assembly Programming Discussion List <ASM370@OHSTVMA> writes:
>I am looking for an assembler macro that will convert the contents of a
>register to printable characters.  IBM is bound to have one floating
>around.  Can anybody lead me in the right direction?

There is no macro that I know of to perform this function.  When I wanted
to perform this, I wrote a routine to do it.  You need to store the register,
perform the next step byte by byte.  Move the low-order byte to the low-order
byte of an 8-byte work area.  Do a MVO of the same byte to the next byte in
the work area.  Continue with each byte.  Do an NC with a mask of 
'OFOFOFOFOFOFOFOF' and that will turn off the high-order bits of the
bytes.  Do a TR on the work field to convert the bytes to display
characters with a table of C'0123456789ABCDEF'.  This will convert
the contents of the register to display in a work area.  I don't have the 
time to code this up now, so I am just providing a description.  If there
is any interest, I could take the time to write the routine, but I assume
that you know IBM Assembler.

------------------------------------------------------------------------------
Ted Conwell                        | Ted.Conwell@Dayton (NCR Internal)
NCR Corporation                    | Ted.Conwell@rd1632.Dayton.NCR.Com (CSNET)
Software Technology, R&D, WHQ-5E   |
1700 S. Patterson Blvd.            |
Dayton, OH 45479                   |
                                   |
(513)445-1298                      |
------------------------------------------------------------------------------

conwell@UUNET.UU.NET (Ted Conwell) (04/10/90)

In article <ASM370%90033009415253@UCF1VM.BITNET> IBM 370 Assembly Programming
        Discussion List <ASM370@OHSTVMA> writes:
>I am looking for an assembler macro that will convert the contents of a
>register to printable characters.  IBM is bound to have one floating
>around.  Can anybody lead me in the right direction?

There is no macro that I know of to perform this function.  When I wanted
to perform this, I wrote a routine to do it.  You need to store the register,
perform the next step byte by byte.  Move the low-order byte to the low-order
byte of an 8-byte work area.  Do a MVO of the same byte to the next byte in
the work area.  Continue with each byte.  Do an NC with a mask of
'OFOFOFOFOFOFOFOF' and that will turn off the high-order bits of the
bytes.  Do a TR on the work field to convert the bytes to display
characters with a table of C'0123456789ABCDEF'.  This will convert
the contents of the register to display in a work area.  I don't have the
time to code this up now, so I am just providing a description.  If there
is any interest, I could take the time to write the routine, but I assume
that you know IBM Assembler.

------------------------------------------------------------------------------
Ted Conwell                        | Ted.Conwell@Dayton (NCR Internal)
NCR Corporation                    | Ted.Conwell@rd1632.Dayton.NCR.Com (CSNET)
Software Technology, R&D, WHQ-5E   |
1700 S. Patterson Blvd.            |
Dayton, OH 45479                   |
                                   |
(513)445-1298                      |
------------------------------------------------------------------------------

jcallen@Encore.COM (Jerry Callen) (04/11/90)

>I am looking for an assembler macro that will convert the contents of a
>register to printable characters.  IBM is bound to have one floating
>around.  Can anybody lead me in the right direction?

The following code fragment is a semi-slick way to convert a value in
a register to printable hex. I didn't invent it; I suspect I learned it
from either Dave Andrews or Clay Brice, my 360 (!) mentors in the early
1970's. It takes advantage of several funky 360/370 features:

- The digits in the second operand of an UNPK instruction are not
  checked for validity.

- The operands of UNPK are allowed to overlap and are processed right to
  left.

- UNPK always supplies a zone nibble of "F", so we don't need to specify
  a complete translate table; we can get away with just the last 16 entries.

WARNING: I don't have access to 370 right now and have not tested this code. 
However, I've used variations on it for years and I'd be surprised if I
screwed it up (but then, it wouldn't be the first time I've screwed up...).

-- Jerry "reformed TSO bigot, now hacking Unix" Callen
   jcallen@encore.com

**********************************************************************
*
*        Convert a value in a register to printable hex. Some requirements
*        and assumptions:
*
*        This is a subroutine in a larger program; that larger program has 
*        established a base register, and its base is far enough back for
*        the HEXTAB equate to work (if this is puzzling, just try it; if
*        it doesn't assemble, you'll get the idea).
*
*        The value to be converted is in R1.
*
*        The return address is in R11 (linkage was via BAL   R11,HEXCNVT).
*
*        This code is NOT reentrant; it is easy to make it so.
*
HEXCNVT  DS    0H
         ST    R1,HEXVALUE                save the value to convert
         UNPK  HEXVALUE(9),HEXVALUE(5)    spread out the nibbles
         TR    HEXVALUE(8),HEXTAB         translate to printable hex
         BR    R11                        return
*
         DS    0F                         word align (not strictly necessary)
HEXVALUE DS    CL9                        hex value ends up in 1st 8 bytes
         DC    C'0123456789ABCDEF'
HEXTAB   EQU   *-256                      pretend we have a complete table

jcallen@HUSC6.HARVARD.EDU (Jerry Callen) (04/11/90)

>I am looking for an assembler macro that will convert the contents of a
>register to printable characters.  IBM is bound to have one floating
>around.  Can anybody lead me in the right direction?

The following code fragment is a semi-slick way to convert a value in
a register to printable hex. I didn't invent it; I suspect I learned it
from either Dave Andrews or Clay Brice, my 360 (!) mentors in the early
1970's. It takes advantage of several funky 360/370 features:

- The digits in the second operand of an UNPK instruction are not
  checked for validity.

- The operands of UNPK are allowed to overlap and are processed right to
  left.

- UNPK always supplies a zone nibble of "F", so we don't need to specify
  a complete translate table; we can get away with just the last 16 entries.

WARNING: I don't have access to 370 right now and have not tested this code.
However, I've used variations on it for years and I'd be surprised if I
screwed it up (but then, it wouldn't be the first time I've screwed up...).

-- Jerry "reformed TSO bigot, now hacking Unix" Callen
   jcallen@encore.com

**********************************************************************
*
*        Convert a value in a register to printable hex. Some requirements
*        and assumptions:
*
*        This is a subroutine in a larger program; that larger program has
*        established a base register, and its base is far enough back for
*        the HEXTAB equate to work (if this is puzzling, just try it; if
*        it doesn't assemble, you'll get the idea).
*
*        The value to be converted is in R1.
*
*        The return address is in R11 (linkage was via BAL   R11,HEXCNVT).
*
*        This code is NOT reentrant; it is easy to make it so.
*
HEXCNVT  DS    0H
         ST    R1,HEXVALUE                save the value to convert
         UNPK  HEXVALUE(9),HEXVALUE(5)    spread out the nibbles
         TR    HEXVALUE(8),HEXTAB         translate to printable hex
         BR    R11                        return
*
         DS    0F                         word align (not strictly necessary)
HEXVALUE DS    CL9                        hex value ends up in 1st 8 bytes
         DC    C'0123456789ABCDEF'
HEXTAB   EQU   *-256                      pretend we have a complete table

terry@uts.amdahl.com (Lewis T. Flynn) (04/12/90)

In article <1035@rd1632.Dayton.NCR.COM> conwell@rd1632.Dayton.NCR.COM (Ted Conwell) writes:
>
>
>In article <ASM370%90033009415253@UCF1VM.BITNET> IBM 370 Assembly Programming Discussion List <ASM370@OHSTVMA> writes:
>>I am looking for an assembler macro that will convert the contents of a
>>register to printable characters.  IBM is bound to have one floating
>>around.  Can anybody lead me in the right direction?
>
>There is no macro that I know of to perform this function.  When I wanted
>to perform this, I wrote a routine to do it.  You need to store the register,
>perform the next step byte by byte.  Move the low-order byte to the low-order
>byte of an 8-byte work area.  Do a MVO of the same byte to the next byte in
>the work area.  Continue with each byte.  Do an NC with a mask of 
>'OFOFOFOFOFOFOFOF' and that will turn off the high-order bits of the
>bytes.  Do a TR on the work field to convert the bytes to display
>characters with a table of C'0123456789ABCDEF'.  This will convert ...

This look likes it works, but I've always seen this done by storing the
value, unpacking it with a length of 5 into a 9 byte area, and TRing
the first eight bytes to convert the 0xFA-0xFF's to 0xC1-0xC6 (or
0x81-0x86) if you want lower case). This gives you what you want in the
first 8 bytes. The 9th byte is trash.

Terry

dandrews@rtmvax.UUCP (David Andrews) (04/14/90)

From article <9004112344.AA08025@ucbvax.Berkeley.EDU>, by encore!jcallen@HUSC6.HARVARD.EDU (Jerry Callen):
> I didn't invent it; I suspect I learned it
> from either Dave Andrews or Clay Brice, my 360 (!) mentors in the early
> 1970's. 

360 days... imagine THAT!

I deny EVER knowing Jerry Callen.
I ESPECIALLY deny ever having anything to do with Clay Brice.


- Avday Andrewsay     tarpit!rtmvax!dandrews