Also, the two byte alignment stuff I wrote before was a brainfart from me... It actually isn't two bytes, but 4... I'm sorry! We could change this actually, but anyway, for now I just added the $PACKRECORDS 2 directives at a few places, which wont' hurt. Also on the subject what you wrote: in this case the danger is not less, but more padding/alignment, so instead of crashes on a 68000 due to byte offsets, the later offsets being completely off. Which actually happened, and got uncovered by me writing some test code.NormanDunbar wrote:Hmm. Usually I code in C/C++ and not Pascal. However, when I'm coding on the PC to read QL structures, I always have to pack the structures to get the correct offsets. I suspect this was simply "muscle memory" in action. I've commented out the packing lines and recompiled the QDOS and SMS examples (in packages/qlunits/examples) and they appear to work fine. However, I'm on QPC which is impersonating/emulating a 68020 and I have fallen foul of that in the past with misaligned words/longwords on byte addresses -- the original QL with its 68008 would have barfed but the 68020 just did what was needed and carried on.
Famous last words indeed. But were caused by my words this time...So I then compiled my own example program which displays all the QDOS System Variables on 5 or so pages. That also worked, so the good news is, unless I'm being 68020'd, is that I didn't need the packing after all. Famous last words?
So here's the test code I wrote for this. Checking like this will uncover if a system variable is badly aligned. Feel free to extend the sysvar_offsets table, but if the last variable is well aligned, then it's usually alright... So I just tested SV_TURBO with this, that was off by 8 whole bytes, then I found out where it got misaligned by checking some offsets in the middle, then I realized why it was aligning some pointer to 4 bytes, instead of two, so added 2 byte alignments. Then everything snapped right into place.