I agree with the KISS method. If it's concatenate then you can do it without the complication. Easily modified to run on OS/360. No need for the complicated moves and the extra register for shifting. Instead just O directly from storage to merge bits and save it back to storage. Here's what I would start with but it is by no means complete, tested or the most efficient. It just gives you a starting point.
DIVISOR DC A(0) Divisor to shift bits LA R4,buffer Current offset into buffer SR R5,R5 (0) Next available bit off of R4 NEXT DS 0H L R15,bitcount Number of bits to append LTR R5,R5 Can we use MVC (bit offset is 0)? BNZ NOTMVC No, * Starting on byte boundary - we can just move the bits without shifting SR R14,R14 0 - needed for divide D R14,=A(8) Calculate offset fields M MVC 0(0,R4),bitlist Copy list of bits EX R15,M Move the data AR R4,R15 Next offset into buffer LR R5,R14 New bit offset * Clear bits that were falsely copied LA R1,=XL1'00,80,C0,E0,F0,F8,FC,FE,FF'(R5) Bits to keep NC 0(1,R4),0(R1) Remove unwanted bits (could overlay next field) J NEXT Append next bit string NOTMVC DS 0H * setup for shifting bits in this field AR R15,R5 Number of bits plus bit offset LA R1,=AL1(1,2,4,8,16,32,64,128)(R5) Point to divisor value for shifting bits MVC DIVISOR+3(1),0(R1) Copy divisor value LA R14,bitlist Start of bits to copy LOOP DS 0H * shift bits and save to result ICM R1,15,0(R14) Get next 4 bytes (may get S0C4 at end of data if crosses page boundary) SR R0,R0 0 D R0,DIVISOR Shift the bits O R1,0(R4) Merge the data STCM R1,15,0(R4) Replace the data (could overlay next field) * Advance pointers for next 3 bytes to copy AHI R4,4 Next available buffer addr AHI R14,4 Next set of bytes AHI R15,-4*8 Adjust length by 4 bytes BP LOOP More bits to be moved from this field * Finished this string - adjust the result pointer / bit offset SR R14,R14 0 for divide LPR R15,R15 Make bit overflow offset positive D R14,=A(8) Calculate next bit offset SR R4,R15 Fix the result pointer LR R5,R14 New bit offset * Clear bits that were falsely copied LA R1,=XL1'00,80,C0,E0,F0,F8,FC,FE,FF'(R5) Bits to keep NC 0(1,R4),0(R1) Remove unwanted bits (could overlay next field) XC 1(3,R4),1(R4) Clear unwanted bits (could overlay next field) J NEXT Move next bit string Jon Perryman ----- Original Message ----- > From: robin <robi...@dodo.com.au> > > Seems unduly and unnecessarily complicated to me. > I'm a believer in the KISS principle. > > From: "Andreas F. Geissbuehler" <afg0...@videotron.ca> > Sent: Tuesday, 6 August 2013 12:30 AM > > Duffy, > Assuing you meant "concatenate" as in appending 57 bits to the end of > a > bitstring of say 395 bits which when done will have grown to 395+57=452 > bits, and "The len of the bit strings to add are 4, 7, 10 BYTES" long > you > could do it WITHOUT register bit shifting loops using old fashion OS/360 > instructions :) Here, the "pseudo code" to explain how: > > Andreas Geissbuehler >