I know how to do it in S5, but cannot remember if you can point indirectly to databits, however, in S5 (probably work in S7/TIA then
L KF 0
T MW10
T MW12 // set the pointers to 0
L DB10.DBD20 //source double word
T MD 200 //transfer to bits
L DB10.DBW22 // load the destination word
T MW 204 // Transfer to bits
Loop:
DO MW10 // do means process indirectly the base of the word pointed to
L M0.0 // indirectly load the bit in temp double word
DO MW 12
T M0.0 transfer indirectly to the destination word
L MW10 // increment the pointers
L Kf 2
+F
T MW10
L MW12
L KF 1
+F
T MW12
L kF 16 //test for all 16 done
<F JC = loop // if not loop back
L MW 10
T DB10.DBW22 // update the destination word
BE
I'm a bit rusty on S7 but I think this would work it will is S7
L KF 0
T MW10
T MW12 // set the pointers to 0
L DB10.DBD20 //source double word
T MD 200 //transfer to bits
L DB10.DBW22 // load the destination word
T MW 204 // Transfer to bits
Loop:
DO MW10 // do means process indirectly the base of the word pointed to
L M0.0 // indirectly load the bit in temp double word
DO MW 12
T M0.0 transfer indirectly to the destination word
L MW10 // increment the pointers
L Kf 2
+F
T MW10
L MW12
L KF 1
+F
T MW12
L kF 16 //test for all 16 done
<F JC = loop // if not loop back
L MW 10
T DB10.DBW22 // update the destination word
BE
I'm a bit rusty on S7 but I think this would work it will is S7