It is enough to include {$ASMMODE INTEL} in mode objfpc?
Much better. Now only push and pop produce errors:
Asm: [push reg32] invalid combination of opcode and operands
Asm: [pop reg32] invalid combination of opcode and operands
Yeah... you forgot to tell me you are on a 64bit platform did you?
Maybe the code from feds works, but usually I would write that with lea syntax for 64 bit.
What you also should do is check what FPC does in pure pascal.
That's because the nutheads that want to write everything in assembler because it is faster are most often (I used to be one of them a long time ago) mistaken.
And it is easier to adapt the assembler output from FPC in something a little! more efficient.
So write in Pascal, compile with -s and examine assembler output. ALWAYS do that first! Specifically here, where there is something the compiler can optimize extremely good because it is so simple for a compiler!
Oh, and you never knew xchg byte ptr bl,al?