Skip to content

[AVR] [Feature] Resolve address of a symbol defined as absolute of another symbol, in assembler code.

ccrause requested to merge ccrause/fpc-source:2022-02-14 into main

Summary

Currently the compiler does not accept a variable defined as absolute to another variable in assembler code. This MR adds the functionality to resolve such a variable to the address of the original variable.

System

This MR will impact all systems that allows assembler and the absolute specifier. It is mostly useful for low level embedded systems such as AVR.

What is the current limitation?

Currently one cannot use a variable declared as follows: RXPORT: byte = absolute PORTB; in an assembler expression. Refer to example below.

What is the behavior after applying this patch?

Correctly resolve the address of TXPORT in example below.

Relevant logs and/or screenshots

The following code generates Error: Unsupported symbol type for operand

program indirect_absolute_asm;

var
  TXPORT: byte absolute PORTB;

begin
  asm
    sbi TXPORT+(-32), 1
  end;
end.

Merge request reports