Re: [cc65] .import struct link_node

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2010-04-27 23:16:13
On Mon, Apr 26, 2010 at 06:37:05AM -0700, Steve Davison wrote:
> Is there any way to share struct definitions between C and asm?

No. You have to manually keep the declarations consistent. 

There's also a problem with nested structs in ca65 that makes the outcome
sometimes unexpected:

        .struct foo
            F1      .word
            F2      .word
            .struct bar
                F3      .word
                F4      .word
            .endstruct
        .endstruct

        baz:    .tag    foo

        lda     baz + foo::bar::F3      ; Get field F3 within foo - ERROR

The reason is that in ca65, .struct is implemented using nested scopes, and
the values of the symbols are the offsets within the struct. This means that
in the code above, foo::bar::F3 resolves to 0 - the offset of F3 in struct
bar. So actually the code above does not access the field F3, but F1 instead.
Correct code would look like this:

        lda     baz + foo::bar + foo::bar::F3

which is slightly more awkward.
                 
Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Apr 27 23:16:21 2010

This archive was generated by hypermail 2.1.8 : 2010-04-27 23:16:24 CEST