In IBM OS/390 assembly, I am trying to do the following:
I have a set of bits that all end in 2 zeroes:
00xxxxxx 00yyyyyy 00zzzzzz
I want to compress them into the following format:
xxxxxxyy yyyyzzzz zz...
I figure that the order will something like
ICM R7,B'1111',FIRSTBUF LOAD 4 BYTES FROM FIRSTBUF INTO REGISTER 7
SLL R7,2 SHIFT ALL BITS LEFT BY 2
STCM R7,B'1000',FINALBUF PASTE THE LEFTMOST BYTE ONLY
SLL R7,2 SHIFT ALL BITS LEFT BY 2
(somehow overwrite only the rightmost 2 bits of the leftmost byte)
STCM R7,B'0100',FINALBUF PASTE SECOND LEFTMOST BYTE
SLL R7,2 SHIFT ALL BITS LEFT BY 2
(somehow overwrite only the right 4 bits of the second byte)
STCM R7,B'0010',FINALBUF PASTE SECOND RIGHTMOST BYTE
SLL R7,2 SHIFT ALL BITS LEFT BY 2
....
Am I on the right track here?
ICM R7,B'1111',FIRSTBUF LOAD 4 BYTES FROM FIRSTBUF INTO REGISTER 7
SLL R7,2 ; Shift away zeros
LR R8,R7 ; Move to a work register
AND R8, 0x3F ; Clear out extra bits.
; First Character complete.
SLL R7,8 ; Remove 1 character and lower 2 bit 0s by shifting away.
LR R9,R7 ; Move to another work register
AND R9, 0x3F ; Clear out extra bits.
SLL R9, 6 ; Shift up to proper location
O R8, R9 ; Drop it in
; Second Character complete.
SLL R7,8 ; Remove 1 character and lower 2 bit 0s by shifting away.
LR R9,R7 ; Move to register
AND R9, 0x3F ; Clear out extra bits.
SLL R9, 14 ; Shift up to proper location
O R8, R9 ; Drop it in
; Third Character complete.
SLL R7,8 ; Remove 1 character and lower 2 bit 0s by shifting away.
LR R9,R7 ; Move to register
AND R9, 0x3F ; Clear out extra bits.
SLL R9, 22 ; Shift up to proper location
O R8, R9 ; Drop it in
; And so on until you want to store the result, or your holder register is full.
I have not coded in this assembler before, but one assembler is a lot like another and the above should demonstrate the ideas of bit manipulation with bitwise and/or combined with shifting. It also buffers I/O by not constatnly writing data to memory, instead using registers to speed things up.
Good luck!