On 03-05-12 13:27, Thomas Schatzl wrote:
...
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;


Thanks guys, I'll try and test this weekend.

Regards,

Koenraad Lelong.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to