News:

Let's find out together what makes a PIC Tick!

Main Menu

Structures and Unions

Started by Gabi, Jun 27, 2022, 07:59 PM

Previous topic - Next topic

Gabi

Sometime I need to use structures or unions to write code in Positron.
In the file attached I have a demo on how I intend to declare and use such types.

My question : if there a way, using Positron syntax and/or ASM only, to have a 'dot' as delimiter between the type and its elements ?

For example,  now I use:

struct_element    // with the "_" as delimiter

and would love to have it like:

struct.element   //

GL & 73
YO4WM


Stephen Moss

Quote from: Gabi on Jun 27, 2022, 07:59 PMMy question : if there a way, using Positron syntax and/or ASM only, to have a 'dot' as delimiter between the type and its elements ?
I would be wary of doing that as in ASM (although not necessarily that produced by Positron) the dot delimiter is already used as in move.l to move a long word, equally Positron already uses the dot delimiter for aliasing, as in Dim Tail as Rat.HighByte. Consequently using an existing delimiter for another purpose could result in complier or other errors/issues as it is then misinterpreted.

Gabi

@atomix
Thank you atomix,
I have tested it and do appreciate your work - wonderful, though I would not use a third party framework at this time.

@Stephen Moss
Many thanks Stephen,
Right, I am aware of compiler's existing uses of the dot delimiter, just thought for myself it would be nice to use in my own defines.

Now I have my thoughts confirmed and concluded, thank you all.



GL & 73
YO4WM

top204

#4
It is something I will be looking into in the future, but it is a very big change to the compiler's code and syntax and operation, so I have to be very careful. Atomix additions are very good, but do not support the structures being passed as a parameter, because that would require a re-write of the parameter handling within the compiler itself using pointers, but I could be incorrect with that statement.

The code changes alone to add structures and unions will take months of work and testing, because I created the compilers from scratch in Borland C++ and did not use a "compiler generator", as most other people do. So it was originally designed as a simple flat language, and all the extras I have added over the years have taken time to do, and re-writes of huge sections of the compiler's source code. The procedure mechanism alone, is something I created myself and uses a mechanism I designed myself and is not in any "compiler writing" books. :-)

keytapper

I understand the hard job to have that in action. For one of my points I like the idea of structs, because they are easy to erase in one go. Also when they would be passed in to a procedure. But this may be a new era, which would approach the gcc compiler. On the other hand,  the old MCUs with memory scattered in banks would be a nightmare to accomplish.
Anyway is just a memory sector with a particular naming scheme, so just stick to byte arrays or strings and adding aliases to part of that area.

One of my proposals is about the use of a loop with a statement FOREACH that would be a similar way
Like a for in conjunction with a lookup table, or any iterable variable. But I think the simpler the better.
Ignorance comes with a cost