Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#struct Directive #135

Open
TChapman500 opened this issue Apr 8, 2022 · 2 comments
Open

#struct Directive #135

TChapman500 opened this issue Apr 8, 2022 · 2 comments

Comments

@TChapman500
Copy link

TChapman500 commented Apr 8, 2022

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.

@justarandomgeek
Copy link

justarandomgeek commented Jan 10, 2024

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.

@TChapman500
Copy link
Author

Interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants