Jump to content
The simFlight Network Forums

adding/using Free OFFSETS in FSUIPC


lamdid

Recommended Posts

Hello everyone, would someone be kind enough to explain to me the meaning of the following sentence (found on page 34 of the FSUIPC For Advanced Users documentation in the paragraph 'Adding Simulator variables (simvars) to FSUIPC offsets'):
"Note also that the offset needs to be bound to the size. This means that if the size is 8, the last offset digit needs to be 0 or 8, if the size is 4, the last offset digit needs to be 0, 4, 8 or C, etc (but not for string types)."

Indeed I would have simply imagined that it is the following offset which had to take into account the size of the one which precedes it.

But this sentence makes me doubt!? Do you have the explanation, thank you

Link to comment
Share on other sites

As it says - the offset address needs to be bound to its size. So, for example if you add a 1 byte simvar to, say, offset A000, the next free offset in that area will be A001. But if you now want to add an int, which is 4-bytes, you cannot add to A001 as that is not on a 4-byte offset boundary. The next position it can be added in will be A004 (the last offset digit needs to be 0, 4, 8 or C, i.e. on a 4-byte boundary).

Link to comment
Share on other sites

This is the sentence I'm having trouble understanding! (I may be a bit limited, sorry): .... But if you now want to add an int, which is 4-bytes, you cannot add to A001 as that is not on a 4-byte offset boundary....

then I understand this: the offset addresses the END of the area allocated by the size at this offset, and not the start?

Link to comment
Share on other sites

I cannot explain it any other way. A 4-byyte value MUST start on a 4-byte boundary.  So the hex address must end in 0, 4, 8 or C. Those are the 4-byte boundaries. If you add an int to an address ending with 0, e.g. xxx0, then the next address available is xxx4, and an int to that, and the next address available is xxx8, add an int to that, and the next address available is xxxC. 4-byte boundary addresses end in 0, 4, 8 or C. 8-byte boundary addresses end in 0 or 8.

Link to comment
Share on other sites

Plenty of resources on boundary data alignment on the web, e.g. https://learn.microsoft.com/en-us/cpp/cpp/alignment-cpp-declarations?view=msvc-170

But I wouldn't worry about this two much. Just remember that the last digit of the offset address must be wholly divisible by the size of the data you are adding, as this will mean that the address is aligned to that data size.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.