[fpc-pascal] Reversing bit-order of byte

Ludo Brands ludo.brands at free.fr
Thu May 3 12:54:56 CEST 2012

> Thanks all for your replies.
> I already found the RBIT-instruction. I also found out I need 
> to study 
> the arm assembly language ;-)
> But how do I get my variable ? Is that in some register ? Is 
> there any 
> documentation about such things ? Then I can use inline assembly.

ARM has different ABI's. A pragmatic solution is to create a full pascal
(inline if you like) function with the function signature you like and a
dummy body, look at the assembler generated (use debug info whe compiling)
and then insert your instructions. For example

Function ReverseBits(b:byte):byte;

  result:=b shl 2;

Look at how result:=b shl 2 is implemented and you'll find immmedialy the
registers used. Next you replace result:=b shl 2 with your asm block.

Note that RBIT is a thumb 2 instruction.


More information about the fpc-pascal mailing list