[fpc-pascal] [OT] inline procedures in TP 7.0

Florian Klämpfl florian at freepascal.org
Sun Feb 16 22:32:06 CET 2020

Am 16.02.20 um 22:28 schrieb Anton Shepelev via fpc-pascal:
> But which registers shall be preserved by inline proceudres
> and functions?

IIRC (it is 25 years ago :)): sp and bp

>  In this example from the manual, the SP
> register is not preserved within the statement:

It is reset to it's value before the parameters were pushed.

>      function LongMul(X, Y: Integer): Longint;
>      inline (
>      $5A/        {POP  AX}
>      $58/        {POP  DX}
>      $F7/$EA);   {IMUL DX}
> Does it mean it shall reset SP to a position before the
> parameters? 

Yes. TP calling conventions means the callee (in this case the inline 
code) clears the stack (remove parameters).

> What about the other registers -- does Turbo
> Pascal take care of them, perhaps enveloping each expansion
> of an inline procedure into a POPs and PUSHes?


More information about the fpc-pascal mailing list