Sometimes I write very short build functions like
function SeniorBit(Value: LongWord): Integer; asm OR EAX,EAX JZ @@Done BSR EAX,EAX INC EAX @@Done: end;
which seems like the best candidate for investment:
function SeniorBit(Value: LongWord): Integer; inline;
but the Delphi compiler does not allow this. Why?
Updated:
Thanks to ldsandon, there is a 5.5 year open QC report . The report contains some suggestions (for example, extending the asm directive) to simplify embedding asm for the compiler. I would prefer to introduce a bare directive at the procedure / function level, which tells the compiler that he does not need to create a stack frame for the procedure and, possibly, which registers (among eax, edx and ecx) should be saved.
If the general task of efficient nesting procedures with BASM code is difficult (and may be inappropriate), it is a good idea to include nesting for the most important cases (for example, a bare function with explicitly declared use of the register).
assembly delphi inlining basm
kludg
source share