`#struct` Directive
TChapman500 opened this issue · 2 comments
I think I know of a good way to define structures. Have a #struct structName {}
directive where each line is a member of the structure. For structure member definitions, #dXX memberName
should be the syntax, just like with any other variable outside of a structure. Perhaps there should also be an optional #memberalign bits
on the first line of the body to force every new member to be aligned to the specified boundary.
Edit: To access members, one would use structName.memberName
, where memberName
is the offset from the start of the structure. It would be up to the developer of the program to provide the correct base pointer.
it's a bit of a hack, but i've found you can do this:
#bankdef struct
{
#bits 32
#addr 0x0000
#size 0x0010
}
#bank struct
#addr 0
structNameA:
.memberA: #res 1
.memberB: #res 1
#bank struct
#addr 0
structNameB:
.memberA: #res 2
.memberB: #res 2
to get labels for structs field offsets. I've put it in a #bank
to itself so the pc-fiddling doesn't screw with anything else.
Interesting.