Nice João, had I read a bit further, I would have noticed your TBIT!  

-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]] On 
Behalf Of Mike Hochee
Sent: Thursday, May 20, 2021 3:58 PM
To: [email protected]
Subject: Re: Macro to set a bit string

Warning! This is a fake (spoofed) message. DO NOT TRUST!

Hi João,

The following (and it may have probs, as it was not tested), simply turns on 
the nth bit within an array. It could be changed to turn off the bit or perform 
some other bit boolean operation. You shouldn't need to iterate through array 
bytes or bits, as that would certainly slow things down. I tried to follow 
Charles' suggestions, but it is very rough and needs checks for out of bounds 
conditions, array size considerations, etc..

HTH,
Mike

*
         XR    R2,R2
         XR    R3,R3
         XR    R4,R4
*
         LAY   R2,12   <=== Input bit to turn on (rel to 0)
         SRDL  R2,3                     /8 to get bytes to bypass
         SRL   R3,29                    shift remainder into pos 61-63
         IC    R4,BitPos(R3)      Prime R4 w/OI immediate value
         LA    R5,BitArray(R2)  A(target byte) in BitArray
         EX    R4,OrBit                Sets selected bit on
*
OrBit    OI    0(R5),x'00'       Set selected bit on in BitArray
*
BitArray DC    XL256'00'
MaxBits  EQU   L'BitArray*8       Max bits in array (rel to 0)
*
BitPos   EQU   *                     Ident bit in target byte
Bit_0    DC    BL1'10000000'
Bit_1    DC    BL1'01000000'
Bit_2    DC    BL1'00100000'
Bit_3    DC    BL1'00010000'
Bit_4    DC    BL1'00001000'
Bit_5    DC    BL1'00000100'
Bit_6    DC    BL1'00000010'
Bit_7    DC    BL1'00000001'
*

-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]] On 
Behalf Of João Reginato
Sent: Thursday, May 20, 2021 2:49 PM
To: [email protected]
Subject: RES: Macro to set a bit string
Importance: Low

Caution! This message was sent from outside your organization.

Thanks to everyone for the relevant notes.
Thank you Philippe for your macro.
Mine follows (just for comparison and understanding) but I've preferred yours:

         MACRO
&NAME    TBIT  &ACT,&VAR,&BIT
&NAME    LR    R14,&BIT
         SR    R15,R15
         SRDL  R14,3
         LA    R14,&VAR.(R14)
         SRL   R15,29
         AIF   ('&ACT' EQ 'OFF').OFF
         IC    R15,=X'8040201008040201'(R15)
         AIF   ('&ACT' EQ 'TEST').TEST
         OI    0(R14),*-*
         EX    R15,*-4
         MEXIT
.TEST    TM    0(R14),*-*
         EX    R15,*-4
         MEXIT
.OFF     IC    R15,=X'7FBFDFEFF7FBFDFE'(R15)
         B     N&SYSNDX
         NI    0(R14),*-*
N&SYSNDX EX    R15,*-4
         MEND

Regards
João

-----Mensagem original-----
De: IBM Mainframe Assembler List <[email protected]> Em nome de 
Philippe Leite Enviada em: quinta-feira, 20 de maio de 2021 15:18
Para: [email protected]
Assunto: Re: Macro to set a bit string

A little fix related to LLILF position:

         MACRO
         TBIT  &ACTION,&ARRAY,&BIT
         LCLC  &TBTIX
&TBTIX   SETC  'TBT'.'&SYSNDX'
         LR    14,&BIT
         SRDL  14,3
         SRL   15,29
         LAY   1,&ARRAY
         LA    1,0(14,1)
         AIF   ('&ACTION' EQ 'ON').ACON
         AIF   ('&ACTION' EQ 'OFF').ACOFF
         AGO   .ERROR1
.ACON    ANOP
&TBTIX.O DS    0H
         LLILF 14,X'00000080'
         LTR   15,15
         JZ    &TBTIX.R
&TBTIX.L DS    0H
         SRL   14,1
         BCT   15,&TBTIX.L
&TBTIX.R DS    0H
         EX    14,&TBTIX.X
         B     &TBTIX.F
&TBTIX.X OI    0(1),0
         AGO   .MEXIT
.ACOFF   ANOP
&TBTIX.N DS    0H
         LLILF 14,X'FFFFFF7F'
         LTR   15,15
         JZ    &TBTIX.S
&TBTIX.M DS    0H
         SRL   14,1
         BCT   15,&TBTIX.M
&TBTIX.S DS    0H
         EX    14,&TBTIX.Y
         B     &TBTIX.F
&TBTIX.Y NI    0(1),0
         AGO   .MEXIT
.ERROR1  ANOP
         MNOTE 8,'*** ACTION PARAMETER INVALID'
         AGO   .MEXIT
.MEXIT   ANOP
&TBTIX.F EQU   *
         MEND



Philippe Leite
z/OS System Programmer

Reply via email to