This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Proposal: GAS, nested structures

On 16.05.13 00:28, Jens Bauer wrote:
> As for myself, I made RSRESET, RSSET, RS.B, RS.H, RS.L macros; these
> do not require sections, as they're only based upon .equ; but this can
> not solve my issue.

They need more work then ... perseverance ... drive ... insight and toil.
(E.g. Does the namespace tweak, outlined in this post, help?)

> What I didn't write was: I did find out how to use it, but it seems to
> me like it can do more than documented.

Using undocumented features can result in elegant macros, but can also
cease working after a decade or more, as support for that succumbs to
bitrot. It is a risk. (Offering to document a discovered useful
behaviour might be cheap insurance.)

> And while searching, I ran into documentation that mentioned 'struct'
> capabilites that the plain GNU Assembler did not support. -I do not
> recall exactly, but I think this one was an extended GAS from Texas
> Instruments.

If it helped your work, maybe ask them if they're inclined to contribute
it? (But some reluctance to maintain more than enough capability to
support gcc was expressed once on this list a while ago, AFAIR.)

> > What was it you found didn't work?
> It works fine, I do not have any problems getting it to work as expected.
> The reason for my post is mainly:
> 1: Make it possible to nest structures
> 2: Most important of all: Allow identical member names in multiple structures, eg.
>    struct Dog { uint16_t legs; uint16_t heads; uint16_t tails; };
>    struct Bird {uint16_t legs; uint16_t wings; uint16_t heads; };

Ah, yes, point 2 offers challenges. (Is it possible that it's time to
retreat to C once we're into that level of complexity?) Even if the
application mostly has e.g. interrupt handlers, hardware initialisation
and drivers, etc. implemented in assembler, a C module links in nicely,
especially if we're only making function calls between them.

But a workmanlike attempt can be made in assembler.
We can modify the "element" macro:

   .altmacro                  ; Allows '&' instead of "\()" separator.

   .macro element struct elem size     ; Struct ID added.
\struct&.\elem:                        ; Element name compounded.
   .struct \struct.\elem + \size
   struct_size = struct_size + \size

Now ldd  r16, Y + mystruct.that_element

provides the per-struct namespace for elements.

> 3: While we're at it, it might make sense to include unions in my proposal.

Well, that's just alternatives with the same start address, I figure.
Off the top of my head it looks easier than nesting.


The Kyoto Protocol, drafted in 1997, aimed to reduce the world's greenhouse gas
emissions by around five per cent from 1990 levels by the end of 2012.
Instead, global greenhouse gases have risen around 58 per cent in that time.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]