ArmMiteF4 BITBANG BITSTREAM Operation


Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2247
Posted: 11:44am 24 Mar 2024      

Some other bit reversal options in this thread.
This one is very clever.
>  b%=73 : ? bin$(b%,8)
01001001
> Rb% = (b% * &H0202020202 and &H010884422010) mod 1023
> ? bin$(Rb%,8)
10010010
>


Footnote added 2024-03-25 07:16 by phil99
Using the above on a 16 bit device code.
> b% = 54321 : ? bin$(b%,16)
1101010000110001
> Rb% = (((b% and 255) * &H0202020202 and &H010884422010) mod 1023) << 8
> Rb% = Rb% + ((b% >> 8) * &H0202020202 and &H010884422010) mod 1023
> ? bin$(Rb%,16)
1000110000101011
>


Footnote added 2024-03-25 07:22 by phil99
Or this.
> b% = 54321 : ? bin$(b%,16)
1101010000110001
> Rb% = (((b% and 255) * &H0202020202 and &H010884422010) mod 1023) << 8
> inc Rb%, ((b% >> 8) * &H0202020202 and &H010884422010) mod 1023
> ? bin$(Rb%,16)
1000110000101011
>