If you have a value in a register, and you want to convert it to printable
HEX, here is a slightly easier method using the Translate instruction (TR)

Hex_conv ds    0h
         st    r5,hexdata
         unpk  charhex(9),hexdata(5)
         tr    charhex(8),convhex-240
        
convhex definition: 
convhex  dc    C'0123456789ABCDEF'
Storage definitions:
hexdata  ds    f,c        
charhex  ds    cl9   

The extra byte after the fullword and the night byte of charhex are
critical.  This works because unpk doesn't verify that the original value is
a valid packed field, it just unpacks what it sees.  Suppose we have:

R5=x'010203CF'

After the store, while we don't char what is the extra byte, lets assume it
is x'00'

After the unpack, charhex will contain:
X'F0F1F0F2F0F3FCFF0C' <== The extra byte is to allow for the sign indicator.

Since we know that the only values that can exist in the first 8 bytes of
hexchar are x'F0'->x'FF' we can ignore the first 240 bytes of the translate
table (for addressability, the definition of the convhex field will need to
be more than 240 (x'F0') bytes into the program.

Now when we do the translate, we will get:
C'010203CF'   

Sorry to the other assembler experts for the long reply, but since the OP is
an assembler newbie, I thought some detail was called for.

Wayne Driscoll
Product Developer
Western Metal Supply
NOTE: All opinions are strictly my own.
 

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to