|
View previous topic :: View next topic
|
| Author |
Message |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
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. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| As a "quickie" you can define as binary, divide by 16 then multiply by 16. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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))
//* |
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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))
//* |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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
leaving the 5th and 8th bits unchanged. There would be nothing to stop the setting of more than one non-contiguous bits either. |
|
| Back to top |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
| Thank you Bill and Kolusu... |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|