Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
kratos86

Active User

Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

Posted: Fri Sep 28, 2012 1:59 pm    Post subject: Assembly NI (AND) operation in SORT

Is there a way to do Assembly level AND operation in SORT

I have the below piece which executes TM and NI instruction
 Code: 1  TM   9(RX),X'0C'    BO   2          2  NI    9(RX),X'F0'

TM instruction is replaced using the BI datatype as shown below.. But not sure about the AND operation.
 Code: SORT FIELDS=COPY                         INREC IFTHEN=(WHEN=(9,1,BI,BO,X'0C'),         BUILD=(???))

Please let me know if this is possible.

Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Fri Sep 28, 2012 2:59 pm    Post subject: Reply to: Assembly NI (AND) operation in SORT As a "quickie" you can define as binary, divide by 16 then multiply by 16.
Skolusu

Senior Member

Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

Posted: Fri Sep 28, 2012 11:43 pm    Post subject: Reply to: Assembly NI (AND) operation in SORT

kratos86,

As bill mentioned you can divide and multiply by 16 treating it as a BI.

Use the following

 Code: //SYSIN    DD *                                          SORT FIELDS=COPY                                      INREC IFTHEN=(WHEN=(9,1,BI,BO,X'0C'),                  OVERLAY=(9:(9,1,BI,DIV,+16),MUL,+16,BI,LENGTH=1))  //*
Skolusu

Senior Member

Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

Posted: Tue Oct 02, 2012 10:12 pm    Post subject:

Alternatively you can use the TRAN=BIT and TRAN=UNBIT parms to get the desired results

Assuming LRECL=80 and RECFM=FB. we first convert the byte at position 9 to bits in position 81 and then replace the end portion with zeros and then use UNBIT to put it back at position 9.
 Code: //SYSIN    DD *                                            SORT FIELDS=COPY                                        INREC IFOUTLEN=80,IFTHEN=(WHEN=(9,1,BI,BO,X'0C'),        OVERLAY=(81:9,1,TRAN=BIT,85:4C'0',9:81,8,TRAN=UNBIT)) //*
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

Posted: Wed Oct 03, 2012 1:03 pm    Post subject: Reply to: Assembly NI (AND) operation in SORT

Another variant. Uses a hex constant (X'...') on SYMNAMES for the '0C' value (since it will be used in two places).

The constant is appended to the end of the record, then a SUBtract, with both fields specified as BInary. May be useful where a bit pattern exists, but where other bits are required to retain their value, zero or non-zero (1).

 Code: //STEP0100 EXEC PGM=SORT //SYMNAMES DD * HEX-0C,X'0C' //SYSOUT   DD SYSOUT=* //SORTOUT  DD SYSOUT=* //SYSIN    DD *   OPTION COPY   INREC IFOUTLEN=80,         IFTHEN=(WHEN=(9,1,BI,BO,HEX-0C),   OVERLAY=(81:HEX-0C,            9:9,1,BI,SUB,81,1,BI,TO=BI,LENGTH=1)) //SORTIN   DD *

EDIT: It is of course possible to arrange to only affect certain bits with Kolusu's neat BIT/UNBIT solution. In the example, it would be

 Code: ...86:2C'0'...

leaving the 5th and 8th bits unchanged. There would be nothing to stop the setting of more than one non-contiguous bits either.
kratos86

Active User

Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

 Posted: Wed Oct 03, 2012 2:32 pm    Post subject: Thank you Bill and Kolusu...
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am How to Generate JCL using Sort naveen katkuri DFSORT/ICETOOL 7 Tue Mar 13, 2018 3:50 pm Need better approach to create a sort... Vamshi Veludandi DFSORT/ICETOOL 8 Thu Mar 08, 2018 5:59 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us