PASM gurus - bit matrix transform challenge
in Propeller 1
In COG I have a bit-matrix 32*8 = 8 consecutive longs
I want to populate them with data from a 32 byte HUB array
in a way, that each byte fills the same bit position in the COG bit-matrix
so first byte ends up in bit position 0 of all 8 longs
and 32nd byte ends up in bit position 31 of all longs
any neat tricks out there?
thanks
MJB
I want to populate them with data from a 32 byte HUB array
in a way, that each byte fills the same bit position in the COG bit-matrix
so first byte ends up in bit position 0 of all 8 longs
and 32nd byte ends up in bit position 31 of all longs
any neat tricks out there?
thanks
MJB

Comments
dat mov Ptr,par ' assuming byte vector is a parameter mov Count,#8 byte_loop rdbyte T,Ptr ' read a byte add Ptr,#1 ' increment the pointer shr T,#1 wc ' C := bit 0 rcr T,M0 shr T,#1 wc ' C := bit 1 rcr T,M1 shr T,#1 wc ' C := bit 2 rcr T,M2 shr T,#1 wc ' C := bit 3 rcr T,M3 shr T,#1 wc ' C := bit 4 rcr T,M4 shr T,#1 wc ' C := bit 5 rcr T,M5 shr T,#1 wc ' C := bit 6 rcr T,M6 shr T,#1 wc ' C := bit 7 rcr T,M7 djnz Count,#byte_loop Done ' more code here Ptr res 1 Count res 1 T res 1 M0 res 1 M1 res 1 M2 res 1 M3 res 1 M4 res 1 M5 res 1 M6 res 1 M7 res 1 fitgood - was thinking of using MUXC to set the values - but shifting RCR in is good thought ... saves the extra mask and shifting it
muxing would give some flexibility if I wanted to insert the byte at random positions into the matrix.
shouldn't your
rcr T,M0 be rcr M0,#1?? or what do I miss?dat mov Ptr,par ' assuming byte vector is a parameter mov Count,#8 mov mymask,#1 byte_loop rdbyte T,Ptr ' read a byte add Ptr,#1 ' increment the pointer shr T,#1 wc ' C := bit 0 muxc M0,mymask shr T,#1 wc ' C := bit 1 muxc M1,mymask shr T,#1 wc ' C := bit 2 muxc M2,mymask shr T,#1 wc ' C := bit 3 muxc M3,mymask shr T,#1 wc ' C := bit 4 muxc M4,mymask shr T,#1 wc ' C := bit 5 muxc M5,mymask shr T,#1 wc ' C := bit 6 muxc M6,mymask shr T,#1 wc ' C := bit 7 muxc M7,mymask shl mymask,#1 ' go for next destination position djnz Count,#byte_loop Done ' more code here Ptr res 1 Count res 1 T res 1 M0 res 1 M1 res 1 M2 res 1 M3 res 1 M4 res 1 M5 res 1 M6 res 1 M7 res 1 mymask res 1 fitYou could do it with:
After 32 bytes, the bits would be in the correct position. The muxc solution is elegant, though. That's one of those instructions that I never use, but probably should be.
You have no initial value for your mask. And the mask just isn't necessary.
No, I was saying your approach was good. It just needed RCL instead of RCR.