lamdid Posted June 9, 2023 Report Posted June 9, 2023 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
John Dowson Posted June 9, 2023 Report Posted June 9, 2023 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).
lamdid Posted June 9, 2023 Author Report Posted June 9, 2023 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?
John Dowson Posted June 9, 2023 Report Posted June 9, 2023 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.
lamdid Posted June 9, 2023 Author Report Posted June 9, 2023 ok thank you it's a little clearer in my head, I'll think about it with a clear head (it's necessary I think). In any case, thank you for your quick response (as usual), Didier
John Dowson Posted June 9, 2023 Report Posted June 9, 2023 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.
lamdid Posted June 9, 2023 Author Report Posted June 9, 2023 thank you for this very interesting information, in addition to the simulation it stimulates the brain well ... these are very good exercises
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now