Hi, On Thu, 2012-05-03 at 12:54 +0200, Ludo Brands wrote: > > 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
We use the standard ARM EABI as gcc uses; for the purpose of this code, it should be sufficient to know that r0 contains the first parameter value, and function values are returned in r0 as well. Without testing, something like the following should be sufficient: function reverse(b : byte) : byte; assembler; nostackframe; asm rbit r0, r0 // rbit reverses the whole word, so now you have // your value in bits 31-24... so shift right by that amount // should fix this up (bits 23-0 contain junk, we shift that out // anyway) lsr r0, r0, #24 end; However, this may not compile because fpc may not recognize the rbit instruction. Following is a version that encodes the instruction directly, retrieved from disassembling some gcc code: function reverse(b : byte) : byte; assembler; nostackframe; asm .long 0xe6ff0f30 // rbit r0, r0 lsr r0, r0, #24 end; Hope this helps; I could not test due to lack of hardware. It may help to use -Cparmv6 and have your (cross-)assembler configured for armv6 code emission. Thomas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal