Article View: comp.lang.asm370
Article #344Packed-Decimal Validation
From: Jim Blalock
Date: Thu, 12 Apr 1990 15:28
Date: Thu, 12 Apr 1990 15:28
34 lines
2317 bytes
2317 bytes
I have a question that surely someone else has answered. I have a need
to validate that data passed to my code is real packed-decimal, in an
attempt to avoid program checks. I've managed to come up with a routine
that should work in all cases, as follows:
MACRO
&TAG PACKCHK &DATA=,&L= DATA=address,L=integer
&TAG XC WORKAREA,WORKAREA Clear workarea first
MVN WORKAREA(&L),&DATA Move 'numerics'
TRT WORKAREA(&L.-1),PACKTBL All numerics but last 00-09?
BNE F1&SYSNDX No, bad input.
CLI WORKAREA+&L.-1,X'0A' Last digit less than x'0a'?
BL F1&SYSNDX Yes, bad sign.
CLI WORKAREA+&L.-1,X'0F' Last digit more than x'0f'?
BNH S1&SYSNDX No: ok so far.
F1&SYSNDX BAS R14,ERRORMSG Issue messages, etc. passing
DC AL2(reasoncode) reason code for error routine
S1&SYSNDX DS 0H Numerics ok:
XC WORKAREA,WORKAREA Wipe workarea again
MVZ WORKAREA+1(&L),&DATA Move zones this time to +1
MVO WORKAREA(&L.+1),WORKAREA(&L.+1) Shift left 4 bits
TRT WORKAREA(&L),PACKTBL 'Zones' within 00-09?
BE S2&SYSNDX Looks ok.
BAS R14,ERRORMSG Issue messages, etc. passing
DC AL2(reasoncode) errexit code
S2&SYSNDX DS 0H Valid packed data: proceed.
MEND
:
PACKTBL DC XL10'00',XL246'FF' Table for 00-09.
WORKAREA DS CL16
This seems to work OK, but it seems like there's a more "elegant"
solution. Anyone have a more clever method that can be generalized
a little?
Technical Details
Message-ID:
<9004122210.AA27201@ucbvax.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!CLEMSON.BITNET!CAREYShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!CLEMSON.BITNET!CAREY From: CAREY@CLEMSON.BITNET (Jim Blalock) Newsgroups: comp.lang.asm370 Subject: Packed-Decimal Validation Message-ID: <9004122210.AA27201@ucbvax.Berkeley.EDU> Date: 12 Apr 90 15:28:00 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: 34