[fpc-pascal] Reversing bit-order of byte
tom_at_work at gmx.at
Fri May 4 14:31:23 CEST 2012
On Fri, 2012-05-04 at 14:14 +0200, Koenraad Lelong wrote:
> On 03-05-12 13:27, Thomas Schatzl wrote:
> > function reverse(b : byte) : byte; assembler; nostackframe;
> > asm
> > .long 0xe6ff0f30 // rbit r0, r0
> > lsr r0, r0, #23
> > end;
> I've been looking a bit further at this.
> I disassembled the code and this is the result :
> 8000150: e6ff0f30 rbit r0, r0
> 8000154: ea4f 50d0 mov.w r0, r0, lsr #23
The constant is wrong here, it should be #24, not #23 imo... typo.
> 8000158: 46f7 mov pc, lr
It might be good to compile with -Cparmv6 (or -Cparmv7, do not know what
type the processor you use is), this generates a "better" return
instruction ("bx lr") - and for the rbit instruction you need armv6
> Wouldn't it be possible to do
> rbit r0, r0, lsr #23
> When reading the ARM programming manual I believe it should.
No, rbit does not allow the "flexible operand" encoding.
> But do I gain something ?
If it were possible, at most a few cpu cycles.
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.
More information about the fpc-pascal