Article View: comp.lang.asm370
Article #340Register Display
From: Jerry Callen
Date: Wed, 11 Apr 1990 15:55
Date: Wed, 11 Apr 1990 15:55
51 lines
2826 bytes
2826 bytes
>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
Technical Details
Message-ID:
<9004112344.AA08025@ucbvax.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!HUSC6.HARVARD.EDU!encore!jcallenShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!HUSC6.HARVARD.EDU!encore!jcallen From: encore!jcallen@HUSC6.HARVARD.EDU (Jerry Callen) Newsgroups: comp.lang.asm370 Subject: Register Display Message-ID: <9004112344.AA08025@ucbvax.Berkeley.EDU> Date: 11 Apr 90 15:55:06 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: IBM 370 Assembly Programming Discussion List <ASM370@OHSTVMA.IRCC.OHIO-STATE.EDU> Distribution: inet Organization: The Internet Lines: 51