[fpc-pascal] Reversing bit-order of byte

Koenraad Lelong koen1 at de-brouwerij.be
Mon May 7 12:59:58 CEST 2012

On 04-05-12 14:53, Koenraad Lelong wrote:
> On 04-05-12 14:31, Thomas Schatzl wrote:
>> Compared to the other variants (e.g. with the multiplies, except for the
>> table lookup) you already save a lot of cycles - although I guess they
>> would be sufficiently fast anyway, considering the typical uart speeds.
>> Thomas
> Hi Thomas,
> My processor flags : -Wpstm32f103rb -Cparmv7m.
> The #23 is no typo, I need to reverse 9 bits. I'm using 9 bit
> synchronous transmission. My first usart-tests were at 4Mbps. The person
> that made the driver recommends max. 6Mbps.


I tested some things this weekend. Strange things happen ;-)
The code does not work. Trying to debug with gdb, around the code I got 
an error, something like 'recovering from a double fault'.

After searching the STM32 forum of ST I found that some toolchains 
assemble the rbit instruction in a wrong way. Someone made a work-around :
	.word	0xFxAyFA9y	//RBIT Rx,Ry x, y = 0 to F
My Freepascal version is this :
     .word	0xFA90
     .word	0xF0A0
Then when I disassemble in gdb, I get rbit r0,r0
Disassembling with objdump gives a strange result.

I'm going to try this as soon as I can.


Koenraad Lelong.

More information about the fpc-pascal mailing list