New Compiler Extensions

  • 1
  • 2
  • Page 1 of 2
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1404
Registered: 03 / 2005
Subject:

New Compiler Extensions

 · 
Posted: 26.07.2021 - 14:12  ·  #1
Firstly I must apologize. I am still having problems with the autodownloader.

I am trying to resolve the issue with Gunter and Rolf.

I have started to implement my first extension to the compiler. It is attached for those who want to try it.

It is my first extension so there are bound to be issues, so any feedback is appreciated.

The extension allows record functions and procedures. This example shows how it it intended to work.

Code
Unit FIFO;

{
  Implements a FIFO buffer, such as used by Serial comms
}

interface
// global part

{ $W+}                  // enable/disable warnings for this unit

uses ;

{--------------------------------------------------------------}
{ Const Declarations }
const

{$IDATA}
{--------------------------------------------------------------}
{ Type Declarations }
type
  tFIFOBuff = record
    Buff : pointer to byte;
    Size : byte;
    addPtr : byte;
    rmvPtr : byte;
    function AddByte( const pByte : byte ) : boolean;
    function RemoveByte( var pByte : byte ) : boolean;
    procedure AssignBuffer( const pBuff : pointer to byte; const pSize : byte );
    function Full : boolean;
    function Empty : boolean;
  end;
  


{--------------------------------------------------------------}
{ Var Declarations }
var

{--------------------------------------------------------------}
{ functions }

implementation
// local part

{--------------------------------------------------------------}
{ Type Declarations }
type

{--------------------------------------------------------------}
{ Const Declarations }
const

{--------------------------------------------------------------}
{ Var Declarations }
{$IDATA}
var

{--------------------------------------------------------------}
{ functions }

function NextByte( const iVal : byte; pLimit : byte  ): byte;
var
  Result : byte;
begin
  Result := iVal + 1;
  if Result = pLimit then
    Result := 0;
  endif;
  return( Result );
end;

function tFIFOBuff.AddByte( const pByte : byte ) : boolean;
var
  iNewPtr : byte;
  iPtr : pointer to byte;
begin
  if Size = 0 then // not initialized
    return( FALSE );
  else
    iNewPtr := NextByte( addPtr, Size );
    if iNewPtr = rmvPtr then
      return( FALSE ); // buffer full
    else
      iPtr :=buff+word(addPtr);
      iPtr^ := pByte;
      addPtr := iNewPtr;
    endif;
  endif;
end;

function tFIFOBuff.RemoveByte( var pByte : byte ) : boolean;
var
  iPtr : pointer to byte;
begin
  if Size = 0 then // not initialized
    return( FALSE );
  else
    if rmvPtr = addPtr then   // empty
      return( FALSE ); // buffer full
    else
      iPtr := buff+word(addPtr);
      pByte := iPtr^;
      rmvPtr := NextByte( rmvPtr, Size );
    endif;
  endif;
end;

function tFIFOBuff.Full : boolean;
var
  iNewPtr : byte;
begin
  if Size = 0 then // not initialized
    return( TRUE );
  else
    iNewPtr := NextByte( addPtr, Size );
    return( iNewPtr = rmvPtr );
  endif;
end;

function tFIFOBuff.Empty : boolean;
begin
  return( rmvPtr = addPtr );
end;

procedure tFIFOBuff.AssignBuffer( const pBuff : pointer to byte; const pSize : byte );
begin
  Buff := pBuff;
  Size := pSize;
  addPtr := 0;
  rmvPtr := 0;
end;

procedure Test;
const
  cSize : byte = 10;
var
  iBuff : array[ 0..cSize - 1] of byte;
  jBuff[ @iBuff ] : byte;
  iFIFO : tFIFOBuff;
  iVal : byte;
begin
  iFIFO.AssignBuffer( @jBuff, cSize );
  iFIFO.AddByte( 7 );
  iFIFO.RemoveByte( iVal );
end;


initialization
// at StartUp

// finalization          // optional
// at System_ShutDown
end FIFO.


Regards
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: New Compiler Extensions

 · 
Posted: 27.07.2021 - 01:20  ·  #2
Quote
The extension allows record functions and procedures.

You put a smile on my face today. Thanks!
miparo
Administrator
Avatar
Gender:
Location: Germany
Age: 58
Posts: 959
Registered: 09 / 2007
Subject:

Re: New Compiler Extensions

 · 
Posted: 27.07.2021 - 12:53  ·  #3
Hi Merlin,
A great step :)

Const as parameter has no function so far in AVRco!

miparo
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1404
Registered: 03 / 2005
Subject:

Re: New Compiler Extensions

 · 
Posted: 27.07.2021 - 16:53  ·  #4
Thanks guys.

I found a couple of issues - fixed here.

Thanks for tip miparo - I'll add it to my to do list. ;-)

There is also a small change to interrupts in UPDI devices.
Attachments
Filename: AVRCo.zip
Filesize: 2.73 MB
Title:
Download counter: 101
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: New Compiler Extensions

 · 
Posted: 30.08.2021 - 09:39  ·  #5
Thinking about potential compiler extensions, implementing type helpers would benefit a lot since we would be allowed to contribute in a way not possible earlier. Type helpers improve code readability and maintainability. Just take a look at https://bitbucket.org/avra/bithelpers and you will get the idea.
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1404
Registered: 03 / 2005
Subject:

Re: New Compiler Extensions

 · 
Posted: 30.08.2021 - 14:17  ·  #6
I am familiar with helpers, Avra. It is a good idea, but a little advanced for me to implement at the moment. I will try to implement in the future, though when I am more familiar with the compiler source.
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: New Compiler Extensions

 · 
Posted: 31.08.2021 - 11:20  ·  #7
Thank you for considering it!
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1404
Registered: 03 / 2005
Subject:

Re: New Compiler Extensions

 · 
Posted: 12.05.2023 - 13:22  ·  #8
I hope this weekend, but if not next weekend, to issue the next release. This will be version 6.00.00, so if you download via the PED it will want to do a full install. This is not necessary so I recommend that you download the update manually from the download page.

I will post a new message when the install is there - I just wanted to forewarn users.

Sadly my 'functions and procedures' idea in records produced too many conflicts, but I have introduced a new construct that I call 'skeleton records' that do have this feature plus properties within records, so check them out. I attach a document outlining the changes.

There are several changes in this release so please make sure that you read the release news (attached).

==============================================================

Ich hoffe, dass ich dieses Wochenende, aber wenn nicht nächstes Wochenende, die nächste Version herausgeben kann. Dies wird die Version 6.00.00 sein, wenn Sie also über das PED herunterladen, wird es eine vollständige Installation durchführen wollen. Dies ist nicht notwendig, so dass ich empfehle, das Update manuell von der Download-Seite herunterzuladen.

Ich werde eine neue Nachricht veröffentlichen, wenn die Installation abgeschlossen ist - ich wollte die Benutzer nur vorwarnen.

Leider hat meine Idee mit den "Funktionen und Prozeduren" in Datensätzen zu viele Konflikte verursacht, aber ich habe ein neues Konstrukt eingeführt, das ich "Skelett-Datensätze" nenne und das diese Funktion sowie Eigenschaften innerhalb von Datensätzen bietet, also sehen Sie es sich an. Ich füge ein Dokument bei, in dem die Änderungen beschrieben sind.

Es gibt mehrere Änderungen in dieser Version, also stellen Sie bitte sicher, dass Sie die Release News (im Anhang) lesen.


Regards

Merlin
Attachments
Revision History
=========================

v6.0.0
-------------------------

Several low level drivers released based on skeleton records. These drivers
map the approriate registers to a record simplifying the creation of a
driver.

Several drivers for Series-0 (UPDI) released by Udi Purwin, with thanks to him.

New 'LIB' files created to supercede previous PCU files. For technical reasons
it is not possible to create new PCU files, although old ones can be read. The new
LIB files perform the same function as the old PCU files. When they are created
an associated file, a .INFO file is created which contains and comments in the
LIB files prefixed with '|||'. This is to allow developers of drivers which they
wish to release as LIB files to document their files without the need to create
a separate file which is difficult to maintain. Please remember that this is an
international product so please document in English if possible.

For Series-0 only, User row implemented.
For all devices User row file creation fixed.

const parameters reverted to non-pointer types because passing non-ram values
(EEPROM, ROM) cannot be detected and caused issues. The restriction that a
const parm cannot be assigned to remains.

StrToInt bug fixed for Series 0 chips
uFAT16_32 PCU updated to include support for slow Intenso (class 4) SD cards
in SDIO Mode.

New feature {$ERROR msg} causes the compiler to generate an error
"SysTick = nnn, user;" mode added for Series 0. Beta - not currently working properly
Error message saying 'Expected Timer0 or Timer2' removed for Series 0 chips.

Profi and Std driver manuals have been merged, since they are no longer separate
products. Many thanks to Thorsten Deck for his help with the German version. The
new manual is named DocuDriver.pdf, but DocuProfiDriver.pdf and DocuStdDriver.pdf
now contain copies of this file so that the new file can be accessed directly
from the PED.
Filename: Release-News.txt
Filesize: 62.03 KB
Title:
Download counter: 133
 
Filename: New Features.pdf
Filesize: 53.42 KB
Title:
Download counter: 98
  • 1
  • 2
  • Page 1 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 17 · Cache Hits: 15   127   142 · Page-Gen-Time: 0.034798s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI