Re: Test Decimal Instruction

2022-03-08 Thread Robin Vowels

From: "Bob Raicer" 
Sent: Wednesday, March 09, 2022 5:04 AM



You might want to consider using this (or a similar) code sequence.
It eliminates the use of EXECUTE instructions and verifies that the
length of the source data is acceptable, i.e., the length is
positive and does not exceed the length of the "work area" (field
PWORK16).  And, of course, it validates the data as being in the
Packed Decimal format.

:  ZAP   PWORK16,KP0  Initialize the area to
: *   receive the Packed Decimal
: *   item.
: *
:  CLFI  R2,L'PWORK16 * Br if the length of the
:  JHNOTGOOD  * source item is greater
: *   * than the length of the
: *   * work area.


The length of a source item is allowed to be longer than that
of the destination, in ZAP.
What matters is whether any significant digits are lost
during the operation.


: *
:  LNR   R15,R2   * Negate the source item
:  JZNOTGOOD  * length and branch if
: *   * zero.


Jump on zero and positive is more robust.


: *
:  LAR14,PWORK16+L'PWORK16(R15)
: *   Set the MVCL 'To' adrs.
:  LRR15,R2   Set the MVCL 'To' length.
:  LRR0,R1Set the MVCL 'From' adrs.
:  LRR1,R2Set the MVCL 'From' length.
: *
:  MVCL  R14,R0   Copy the source item to
: *   the work area (right aligned).
: *
:  TPPWORK16  * Verify the copy of the
:  JNZ   NOTGOOD  * source item is valid
: *   * Packed Decimal format.
: *
: * - do something with the validated data.
: *
: *
: NOTGOOD  DC0H'0'
:  MVC MACRO,=CL8'CONVERT'
:  LR  R5,R7
:  LHI R15,-7
:  B   RETERR
: *
: KP0  DCPL1'0'


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


Re: Test Decimal Instruction

2022-03-08 Thread Bob Raicer

You might want to consider using this (or a similar) code sequence.
It eliminates the use of EXECUTE instructions and verifies that the
length of the source data is acceptable, i.e., the length is
positive and does not exceed the length of the "work area" (field
PWORK16).  And, of course, it validates the data as being in the
Packed Decimal format.

[Note:  I shifted the code right a couple of columns and put a
non-blank in column one to avoid strange text flowing problems with
the list server system.]

:  ZAP   PWORK16,KP0  Initialize the area to
: *   receive the Packed Decimal
: *   item.
: *
:  CLFI  R2,L'PWORK16 * Br if the length of the
:  JHNOTGOOD  * source item is greater
: *   * than the length of the
: *   * work area.
: *
:  LNR   R15,R2   * Negate the source item
:  JZNOTGOOD  * length and branch if
: *   * zero.
: *
:  LAR14,PWORK16+L'PWORK16(R15)
: *   Set the MVCL 'To' adrs.
:  LRR15,R2   Set the MVCL 'To' length.
:  LRR0,R1Set the MVCL 'From' adrs.
:  LRR1,R2Set the MVCL 'From' length.
: *
:  MVCL  R14,R0   Copy the source item to
: *   the work area (right aligned).
: *
:  TPPWORK16  * Verify the copy of the
:  JNZ   NOTGOOD  * source item is valid
: *   * Packed Decimal format.
: *
: * - do something with the validated data.
: *
: *
: NOTGOOD  DC0H'0'
:  MVC MACRO,=CL8'CONVERT'
:  LR  R5,R7
:  LHI R15,-7
:  B   RETERR
: *
: KP0  DCPL1'0'


Re: Test Decimal Instruction

2022-03-08 Thread Dave Clark
"IBM Mainframe Assembler List"  wrote on 
03/07/2022 06:44:52 PM:
> The code is not robust.  You need to test for R2 being negative
> after you subtract 1 from it.

A greater than zero test is performed previous to the instructions 
shown.


> Why AHI R2,-(1) and not AHI R1,-1   ?

It actually comes from an SHI macro I created.


> TP requires the length in a different place from ZAP.
> You need to shift R2 left by 4 places, before executing TP.
> Then, you need to shift R2 right by 4 places, before executing ZAP.

Yes, that is what my second post said.  Thanks.


> Why do you need the TP instruction?
> ZAP tests the second operand for valid sign and valid digits.

Because ZAP produces a program exception where TP does not.


Sincerely,

Dave Clark
-- 
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300

Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio  45439  USA
(937) 294-5331





*
This email message and any attachments is for use only by the named 
addressee(s) and may contain confidential, privileged and/or proprietary 
information. If you have received this message in error, please 
immediately notify the sender and delete and destroy the message and all 
copies. All unauthorized direct or indirect use or disclosure of this 
message is strictly prohibited. No right to confidentiality or privilege 
is waived or lost by any error in transmission. 
*


Re: Test Decimal Instruction

2022-03-07 Thread Charles Mills
> Why AHI R2,-(1) and not AHI R1,-1   ?

Looks like macro generated code to me, and -(1) is perfectly valid.

> ZAP tests the second operand for valid sign and valid digits

But returns the result of the test in a more dramatic fashion than TP.

Charles


-Original Message-
From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@LISTSERV.UGA.EDU]
On Behalf Of Robin Vowels
Sent: Monday, March 7, 2022 3:45 PM
To: ASSEMBLER-LIST@LISTSERV.UGA.EDU
Subject: Re: Test Decimal Instruction

On 2022-03-08 09:16, Dave Clark wrote:
> I'm confused...  I don't understand why the TEST DECIMAL
> instruction is rejecting the following situation.  Instead of dropping
> down to the second execute instruction, it is falling into the error
> reporting logic.  Why is that?
> 
> 
> R1 => x'0108010C'
> R2 == 4
> 
>  AHI   R2,-(1)
> IF0027   DS0H
>  EXR2,TEST_IT
>  BZELSE0027
> THEN0027 DS0H
>MVC MACRO,=CL8'CONVERT'
>LR  R5,R7
>LHI R15,-7
>B   RETERR
> TEST_IT  TP0(0,R1)
> ZAP_IT   ZAP   PWORK16,0(0,R1)
> ELSE0027 DS0H
> ENDF0027 DS0H
>  EXR2,ZAP_IT

And PWORK16?
Better to include the assembler listing for the segment, including 
PWORK16.

The code is not robust.  You need to test for R2 being negative
after you subtract 1 from it.

Why AHI R2,-(1) and not AHI R1,-1   ?

TP requires the length in a different place from ZAP.
You need to shift R2 left by 4 places, before executing TP.
Then, you need to shift R2 right by 4 places, before executing ZAP.

Why do you need the TP instruction?
ZAP tests the second operand for valid sign and valid digits.


Re: Test Decimal Instruction

2022-03-07 Thread Robin Vowels

On 2022-03-08 09:16, Dave Clark wrote:

I'm confused...  I don't understand why the TEST DECIMAL
instruction is rejecting the following situation.  Instead of dropping
down to the second execute instruction, it is falling into the error
reporting logic.  Why is that?


R1 => x'0108010C'
R2 == 4

 AHI   R2,-(1)
IF0027   DS0H
 EXR2,TEST_IT
 BZELSE0027
THEN0027 DS0H
   MVC MACRO,=CL8'CONVERT'
   LR  R5,R7
   LHI R15,-7
   B   RETERR
TEST_IT  TP0(0,R1)
ZAP_IT   ZAP   PWORK16,0(0,R1)
ELSE0027 DS0H
ENDF0027 DS0H
 EXR2,ZAP_IT


And PWORK16?
Better to include the assembler listing for the segment, including 
PWORK16.


The code is not robust.  You need to test for R2 being negative
after you subtract 1 from it.

Why AHI R2,-(1) and not AHI R1,-1   ?

TP requires the length in a different place from ZAP.
You need to shift R2 left by 4 places, before executing TP.
Then, you need to shift R2 right by 4 places, before executing ZAP.

Why do you need the TP instruction?
ZAP tests the second operand for valid sign and valid digits.


Re: Test Decimal Instruction

2022-03-07 Thread Charles Mills
Don't forget to reset R2 for the ZAP!

Charles


-Original Message-
From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@LISTSERV.UGA.EDU]
On Behalf Of Dave Clark
Sent: Monday, March 7, 2022 2:25 PM
To: ASSEMBLER-LIST@LISTSERV.UGA.EDU
Subject: Re: Test Decimal Instruction

"IBM Mainframe Assembler List"  wrote on 
03/07/2022 05:16:50 PM:
> I'm confused...  I don't understand why the TEST DECIMAL 
> instruction is rejecting the following situation.  Instead of dropping 
> down to the second execute instruction, it is falling into the error 
> reporting logic.  Why is that?
> 
> 
> R1 => x'0108010C'
> R2 == 4
> 
>  AHI   R2,-(1) 
> IF0027   DS0H 
>  EXR2,TEST_IT 
>  BZELSE0027 
> THEN0027 DS0H 
>MVC MACRO,=CL8'CONVERT'
>LR  R5,R7 
>LHI R15,-7 
>B   RETERR 
> TEST_IT  TP0(0,R1)
> ZAP_IT   ZAP   PWORK16,0(0,R1) 
> ELSE0027 DS0H 
> ENDF0027 DS0H 
>  EXR2,ZAP_IT


Ah, I think I know why.  It is because I am executing the TP 
instruction and the length of the first operand is supposed to be in bits 
8 to 11 instead of bits 12 to 15 where my length from R2 would end up.


Sincerely,

Dave Clark
-- 
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300

Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio  45439  USA
(937) 294-5331





*
This email message and any attachments is for use only by the named 
addressee(s) and may contain confidential, privileged and/or proprietary 
information. If you have received this message in error, please 
immediately notify the sender and delete and destroy the message and all 
copies. All unauthorized direct or indirect use or disclosure of this 
message is strictly prohibited. No right to confidentiality or privilege 
is waived or lost by any error in transmission. 

*


Re: Test Decimal Instruction

2022-03-07 Thread Charles Mills
L1 appears to be in the bits 8-11 nibble. Try an SLL 4 on R2.

Charles


-Original Message-
From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@LISTSERV.UGA.EDU]
On Behalf Of Dave Clark
Sent: Monday, March 7, 2022 2:17 PM
To: ASSEMBLER-LIST@LISTSERV.UGA.EDU
Subject: Test Decimal Instruction

I'm confused...  I don't understand why the TEST DECIMAL 
instruction is rejecting the following situation.  Instead of dropping 
down to the second execute instruction, it is falling into the error 
reporting logic.  Why is that?


R1 => x'0108010C'
R2 == 4

 AHI   R2,-(1) 
IF0027   DS0H 
 EXR2,TEST_IT 
 BZELSE0027 
THEN0027 DS0H 
   MVC MACRO,=CL8'CONVERT'
   LR  R5,R7 
   LHI R15,-7 
   B   RETERR 
TEST_IT  TP0(0,R1)
ZAP_IT   ZAP   PWORK16,0(0,R1) 
ELSE0027 DS0H 
ENDF0027 DS0H 
 EXR2,ZAP_IT


Sincerely,

Dave Clark
-- 
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300

Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio  45439  USA
(937) 294-5331




*
This email message and any attachments is for use only by the named 
addressee(s) and may contain confidential, privileged and/or proprietary 
information. If you have received this message in error, please 
immediately notify the sender and delete and destroy the message and all 
copies. All unauthorized direct or indirect use or disclosure of this 
message is strictly prohibited. No right to confidentiality or privilege 
is waived or lost by any error in transmission. 

*


Re: Test Decimal Instruction

2022-03-07 Thread Dave Clark
"IBM Mainframe Assembler List"  wrote on 
03/07/2022 05:16:50 PM:
> I'm confused...  I don't understand why the TEST DECIMAL 
> instruction is rejecting the following situation.  Instead of dropping 
> down to the second execute instruction, it is falling into the error 
> reporting logic.  Why is that?
> 
> 
> R1 => x'0108010C'
> R2 == 4
> 
>  AHI   R2,-(1) 
> IF0027   DS0H 
>  EXR2,TEST_IT 
>  BZELSE0027 
> THEN0027 DS0H 
>MVC MACRO,=CL8'CONVERT'
>LR  R5,R7 
>LHI R15,-7 
>B   RETERR 
> TEST_IT  TP0(0,R1)
> ZAP_IT   ZAP   PWORK16,0(0,R1) 
> ELSE0027 DS0H 
> ENDF0027 DS0H 
>  EXR2,ZAP_IT


Ah, I think I know why.  It is because I am executing the TP 
instruction and the length of the first operand is supposed to be in bits 
8 to 11 instead of bits 12 to 15 where my length from R2 would end up.


Sincerely,

Dave Clark
-- 
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300

Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio  45439  USA
(937) 294-5331




*
This email message and any attachments is for use only by the named 
addressee(s) and may contain confidential, privileged and/or proprietary 
information. If you have received this message in error, please 
immediately notify the sender and delete and destroy the message and all 
copies. All unauthorized direct or indirect use or disclosure of this 
message is strictly prohibited. No right to confidentiality or privilege 
is waived or lost by any error in transmission. 
*


Test Decimal Instruction

2022-03-07 Thread Dave Clark
I'm confused...  I don't understand why the TEST DECIMAL 
instruction is rejecting the following situation.  Instead of dropping 
down to the second execute instruction, it is falling into the error 
reporting logic.  Why is that?


R1 => x'0108010C'
R2 == 4

 AHI   R2,-(1) 
IF0027   DS0H 
 EXR2,TEST_IT 
 BZELSE0027 
THEN0027 DS0H 
   MVC MACRO,=CL8'CONVERT'
   LR  R5,R7 
   LHI R15,-7 
   B   RETERR 
TEST_IT  TP0(0,R1)
ZAP_IT   ZAP   PWORK16,0(0,R1) 
ELSE0027 DS0H 
ENDF0027 DS0H 
 EXR2,ZAP_IT


Sincerely,

Dave Clark
-- 
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300

Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio  45439  USA
(937) 294-5331



*
This email message and any attachments is for use only by the named 
addressee(s) and may contain confidential, privileged and/or proprietary 
information. If you have received this message in error, please 
immediately notify the sender and delete and destroy the message and all 
copies. All unauthorized direct or indirect use or disclosure of this 
message is strictly prohibited. No right to confidentiality or privilege 
is waived or lost by any error in transmission. 
*