We are writing real time software in embedded C for the PowerPC 604.
What follows, is a conversation between two of my colleagues. I'm having a difficult time understanding what they are talking about.
Employee 1:
In the PPC architecture, must integer alignment follow word boundaries? This is related to whether the pointer stack math/comparisons might be better served as cast to integer pointers instead of char pointers. If PPC guarantees word alignment then seeing pointer values that are not word aligned seems it would be an additional check-able red-flag, whereas char pointers could by their nature be odd address values 3/4 of the time...just a thought that came to me...am I totally off-base?
Employee 2:
Only floating point values must be on 4-byte aligned memory address. All other values do not have this requirement. This is why we have 4-byte alignment checks when parsing network packets (which can be at any byte offset in the packet as sent). WORD alignment is not guaranteed otherwise.
Employee 1:
I probably didn't state my issue satisfactorily. In the PPC architecture pointers should generally have word boundary values unless they are pointing to values in a vector of characters. The architecture makes every effort to align all non-vector values to word boundaries. This allows for an additional corruption check such that if a pointer value is **not on a four byte boundary and does not point to an element in a packed struct then it probably means data has been corrupted...That was my only point.
Employee 2:
I think you misunderstood my answer. Unless they changed it, which could very well be true, that it not the case. WORD alignment is not guaranteed and a check against WORD alignment tells us nothing. The corruption check would not be possible this way. I specifically looked this up in the old documentation several years ago, and they certainly could have changed it. We would need to find proof of this though. The only data type that is guaranteed to be placed on a word aligned memory address are floats and it's a compiler option, not an architecture requirement.
Employee 1:
I've got "the proof" if you want to see it. unless the data is explicitly packed or is a char vector index it will reside at an address ending in [0,4,8,c] on PPC.
I'm very confused. Vector? They must be referring to arrays. How much of this information makes sense, and how much of it is questionable?
What are the rules for data alignment and word boundaries?
What are they trying to determine?