[fpc-devel] Help with inline assembler code

Jeppe Johansen jeppe at j-software.dk
Wed Mar 29 21:45:06 CEST 2023


Hi,

A much more deterministic version would do it as this:

function HiInteger(value: LongInt): LongInt; nostackframe; assembler;
asm
   mov r0, r0, asr #16
end;

If you do it with an inline ASM block and without stackframes it becomes 
much harder to predict how you need to address variables by name

Best Regards,
Jeppe

On 3/29/23 15:47, Paul Renaud via fpc-devel wrote:
> Hello,  I've been having a problem getting some code to compile.  I've 
> gone through the documentation, but
> there isn't any specific info for the arm version. This is a 
> simplified version
>
> Program Test;
>
>   Function HiInteger( Value: LongInt ): LongInt;
>     Begin
>       Asm
>         LdR R0, Value
>         Mov R1, R0, ASR #16
>         StR R1, @Result         (* This line generates an error *)
>        End [ 'R0', 'R1' ];
>      End;
>
>   Begin
>   End.
>
> Free Pascal version 3.2.2 for arm
>
> Thanks for any help in advance.
> Paul.
>
>
> _______________________________________________
> fpc-devel maillist  -fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20230329/ca9d1b56/attachment.htm>


More information about the fpc-devel mailing list