[fpc-pascal] Reversing bit-order of byte
Geoffrey Barton
mrb at periphon.net
Mon May 7 15:38:16 CEST 2012
On 7 May 2012, at 13:26, fpc-pascal-request at lists.freepascal.org wrote:
>
>
> Message: 4
> Date: Mon, 07 May 2012 12:59:58 +0200
> From: Koenraad Lelong <koen1 at de-brouwerij.be>
> Subject: Re: RE : RE : [fpc-pascal] Reversing bit-order of byte
> To: fpc-pascal at lists.freepascal.org
> Message-ID: <4FA7AB2E.9050706 at de-brouwerij.be>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> 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.
>
> Hi,
>
> 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.
>
> Regards,
>
> Koenraad Lelong.
I have beed using this:-
function bitreverse(input:dword):dword;assembler;nostackframe; {single instruction rbit r0,r0 bit reverses r0}
asm
.long 0xf0a0fa90
end;
quite successfully.
You can then choose which byte(s) you need using normal pascal functions.
regards,
Geoffrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20120507/1b00d192/attachment.html>
More information about the fpc-pascal
mailing list