Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2023-03

Help with inline assembler code

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Paul Renaud

Hello,  I've been having a problem getting some code to compile.  I've gone through the documentation, butthere 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.

Reply by email

Jeppe Johansen
to Paul Renaud

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

Paul Renaud wrote 28 lines
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 https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email