On Sat, Jan 9, 2021 at 3:52 PM Jonas Maebe via fpc-devel <
fpc-devel@lists.freepascal.org> wrote:

> On 08/01/2021 22:00, Christo Crause via fpc-devel wrote:
> > However I see problems with propagating section information through
> > reference type parameters. I'm not sure how to propagate the section
> > information of the variable "w" through the parameter
>
> Can't you use something like the far pointers used on the 8086 target? (
> (a regular pointer only contains an offset, a far pointer contains both
> a segment and an offset) If so, the main downside is that it would
> increase the size of all reference parameters to include room for the
> section part of the pointer, unless you add a directive to disable that
> (or couple it to the existing farpointers directive).
>

Thanks for the idea Jonas. This could be a solution as is, but as you
mentioned it comes with a parameter size penalty.  Using a generic offset
for the section (unknown at compile time on the callee side) would require
runtime handing of the different access methods to the different address
spaces, increasing code size.  These two concerns are deal breakers for
microcontrollers (at least in my opinion).

Could your idea not be simplified by allowing the use of the section
directive when defining a pointer?
type
  Peeprom = pointer; section '.eeprom';

This way when a parameter is defined as e.g. type Peeprom the compiler
knows what access code should be generated for the specified section.  It
would also help with compile time error checking where assigning a regular
pointer to a section pointer should not be allowed (unless the user applies
a type cast).
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to