Seems unduly and unnecessarily complicated to me. I'm a believer in the KISS principle.
From: "Andreas F. Geissbuehler" <[email protected]> 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: A DC XL16'00' work area A B DC XL16'00' work area B STR DC B'011011101011000111' source needs alignement 0..7 bits TBL DC 64AL1((*-TBL)*2) to do 1-bit "shift-left' * ALIGN BITS TO BE ADDED/APPENDED: * 2 regs are needed: * Rp addr.pointer to right-most byte of target * Rn number of significant bits in that byte LTR R0,Rn JNP noshift required MVO B,STR assume 4-bit shift N R0,=F'3' apply AND-mask JZ X needed 4-bit shift only UNPK A,STR makes space for bit shift MVZ A,=16X'00' clears hi-nibble T TR A,TBL repeat this "SHIFT-LEFT" 0..2 times BCT R0,T MVO B,A aligns A for PACK MVO A,B aligns B for OC OC B,A "doubles" up the shifted nibbles PACK A,B chop bitstring on new nibble boundary MVC B,A assume we are done CHI Rn,4 test bit count JNH *+10 fewer than 4 bits MVO B,A shift another 4 bits X OC 0(n,Rp).B append new bits to target "bitstring" LA Rp, ... update addr.ptr for next append AR Rn, ... prev.no. of signifant bit + newly appended N Rn,=F'7' = significant bits at Rp You need offset and length adjustments, e.g, MVO A+1(L'A-1),B to get extra work bits and keeps the packed decimal sign bits out of bitstring. An MVO by itself does a shift of 4-bits... Let's play Computer ! To make it easier for our eye we assign a symbolic name to each bit in STR above: | abcd | efgh | ijkl | mnop | qr__ | 18 bits in 5 nibbles After the initial UNKP and MVZ the bits are spaced out like this: ____abcd____efgh____ijkl____mnop____qr__ The TR doubles the value of each nibble, eg. 0000 stays 0000 wheras 0011 -> 0110 and 1111 -> [0001]1110, thus: ___abcd.___efgh.___ijkl.___mnop.___qr.__ after 1st "shift left" __abcd..__efgh..__ijkl..__mnop..__qr..__ after 2dn TR A,TBL _abcd..._efgh..._ijkl..._mnop..._qr...__ after 3rd TR A,TBL MVO B.A gets us new zone bit space #### ####_abcd..._efgh..._ijkl..._mnop..._qr...__ MVO A,B aligns 2nd operand for OC "or" ########_abcd..._efgh..._ijkl..._mnop..._qr...__ OC A,B "re-inserts" bits shifted out of lo-nibble into hi-nibble. Note: To mark vacated bits I used underscores and dots in above illustrations to show the effets of UNPK and bit shift. ####_abcdabcdefghefghijklijklmnopmnopqr__qr__ PACK B(8),A(15) removes "duplicates" and chops it up into a useable string ####_abc####defg####hijk####lmno####pqr__ result: | 0abc | defg | hjik | lmno | pqr0 | .... The final OC does the append. I got carried away... I hope you like it :) although it is an alternative to register shift loops, it isn't obvious (to me!) that it is better in any way... Andreas Geissbuehler
