Sign in Join

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

Mailing lists / fpc-pascal / 2018-02

Cannot reference macro identifier in assembler code

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Christo

The following code doesn't compile for the AVR target (FPC 38288):

program macrotest;
begin
  asm
  {$ifdef FPC_SRAMSIZE}
    sts FPC_SRAMSIZE , r31  // macrotest.pp(5,9) Error: Unknown identifier "FPC_SRAMSIZE"
  {$endif}
  end;
end. 

Is the use of macros in assembler blocks allowed?

(Compiled with: ~/fpc/3.1.1/compiler/avr/pp -Wpattiny13 -Sgm macrotest.pp)

Clearly the ifdef check passed so FPC_SRAMSIZE is defined, however when the macro is used FPC doesn't recognize it.  If the macro reference is moved outside the asm block to a const then it works as expected (to some degree, there is another problem unrelated to the use of a macro). This code compiles as expected:

program macrotest;
const
  sramSize = FPC_SRAMSIZE;
begin
  asm
    sts sramSize , r31
  end;
end.