Recent

Author Topic: AVR microcontroller unit format  (Read 22810 times)

ccrause

  • Hero Member
  • *****
  • Posts: 843
Re: AVR microcontroller unit format
« Reply #45 on: December 14, 2017, 09:48:35 pm »
Pascal users have already adopted single letter T prefix (as in TMyType) for type declarations, P prefix for pointers (as in PMyRecord), I prefix for interfaces (as in IMyInterface), and F prefix for fields (as in FMyField). I would exploit such habbit and naming convention, and simply extend it by defining X prefix for bits in a set (as xCF0A) and M prefix for bit masks (as mCF0A). And yes, I would prefer those two single letter prefixes to be lower case since that would visually more stand out during code completetion and ease distinction quite a bit.
So far e and m prefixes generate identifier clashes. s seems good to use for the set element names.
Quote
I do not see a problem with forcing variables to be stored into specific registers. A typical AT MEGA memory map starts with something like 0x0000 – 0x001F (registers R0 – R31). So all we need is to try it this way:
Code: Pascal  [Select][+][-]
  1. var
  2.   R0: byte absolute $00; // these definitions should go to cpu unit
  3.   R1: byte absolute $01;
  4.   // ...
Code: Pascal  [Select][+][-]
  1. var
  2.   MyByte: byte absolute R0; // these definitions go to user code
  3.  
Of course we need to be extra carefull, but it is doable.
This concept does kind of work (except for r0: byte absolute 0;). The one problem remains the adopted ABI which in principle consume all general CPU registers. Another problem is the access to the underlying register via the variable - this requires LDS/STS instructions, which then needs to put the data into... some register :o. Probably useful for user code debugging tricks which dump register content, but not useful to speed up critical data access.
Quote
I would also like to be able to define address after absolute keyword only on first variable, and then compiler takes care of all following variables having absolute keyword without address parameter. Unfortunatelly that is not possible with FPC, but sounds like a good candidate for a feature request.
Has been possible in FPC trunk for a couple of months now.
« Last Edit: December 14, 2017, 09:55:35 pm by ccrause »

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: AVR microcontroller unit format
« Reply #46 on: December 15, 2017, 09:13:40 pm »
Pascal users have already adopted single letter T prefix (as in TMyType) for type declarations, P prefix for pointers (as in PMyRecord), I prefix for interfaces (as in IMyInterface), and F prefix for fields (as in FMyField). I would exploit such habbit and naming convention, and simply extend it by defining X prefix for bits in a set (as xCF0A) and M prefix for bit masks (as mCF0A). And yes, I would prefer those two single letter prefixes to be lower case since that would visually more stand out during code completetion and ease distinction quite a bit.
So far e and m prefixes generate identifier clashes. s seems good to use for the set element names.
I was advocating for more pascal like single letter prefix without underscore. That is not the case now.

Quote
I would also like to be able to define address after absolute keyword only on first variable, and then compiler takes care of all following variables having absolute keyword without address parameter. Unfortunatelly that is not possible with FPC, but sounds like a good candidate for a feature request.
Has been possible in FPC trunk for a couple of months now.
No, that's not what I meant. Maybe I didn't explain well. Here it is in code:
Code: Pascal  [Select][+][-]
  1.   x: byte absolute $100;
  2.   y: word absolute; // this should automatically point to $101
  3.   z: float absolute; // this should automatically point to $103

That is not possible. I have just tried with today's trunk.
« Last Edit: December 15, 2017, 09:18:08 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

ccrause

  • Hero Member
  • *****
  • Posts: 843
Re: AVR microcontroller unit format
« Reply #47 on: December 16, 2017, 07:01:48 am »
Pascal users have already adopted single letter T prefix (as in TMyType) for type declarations, P prefix for pointers (as in PMyRecord), I prefix for interfaces (as in IMyInterface), and F prefix for fields (as in FMyField). I would exploit such habbit and naming convention, and simply extend it by defining X prefix for bits in a set (as xCF0A) and M prefix for bit masks (as mCF0A). And yes, I would prefer those two single letter prefixes to be lower case since that would visually more stand out during code completetion and ease distinction quite a bit.
So far e and m prefixes generate identifier clashes. s seems good to use for the set element names.
I was advocating for more pascal like single letter prefix without underscore. That is not the case now.
The reason I started using underscores was to avoid identifier clashes.  I'm in favour of your suggestion, I just need to go through a couple of iterations of picking prefixes, generate units, compile all units.

ccrause

  • Hero Member
  • *****
  • Posts: 843
Re: AVR microcontroller unit format
« Reply #48 on: December 16, 2017, 07:03:46 am »
Code: Pascal  [Select][+][-]
  1.   x: byte absolute $100;
  2.   y: word absolute; // this should automatically point to $101
  3.   z: float absolute; // this should automatically point to $103

That is not possible. I have just tried with today's trunk.
Ah, I see.  That is indeed not possible with current compiler.

 

TinyPortal © 2005-2018