Un-alignment in structures
Norman Diamond
ndiamond at watdaisy.UUCP
Fri Mar 22 10:41:29 AEST 1985
> When asking for unaligned structures in C, don't forget to ask that
> they be unaligned at the BIT level, because you might want to read
> tapes containing 36 or 60 bit words.
A 36-bit or 60-bit machine already has to make adjustments, regardless of
programming language or compiler or options. 9-track tapes, with 1 parity
bit, have 8-bit bytes written on them. Similarly, networks are generally
specified to have 7-bit or 8-bit data, or 7-bit padded with a zero bit or
with parity. The machine already must do some conversion. Why make it
so much harder for a C programmer to complete the conversion?
> Also make sure that the compiler
> supports viewing numbers as having their bytes interchanged, because you
> might want to go from the VAX to something sane, occasionally.
If a machine's ports reverse the bytes from the protocol specified by the
network, then that machine's programs must make adjustments. Again, why
should C make it harder?
Or if it's on tape, it is already known that data other than character
strings cannot really be regarded as portable.
> So we'll have to go
> with the next-best thing: a library of good, generic data-conversion routines.
> Fortunately, C provides lots of support for writing generic procedures.
But to overcome the padding, they will have to be in assembly or will have to
convert bytes (out of a char array) into ints. For that matter, even the
char array doesn't work well on some machines; it may have to be assembly.
Yes I understand the earlier suggestion about a smiley face -- though the
submission wasn't just a joke, it was rhetoric with a certain message
intended. I replied to the message.
--
Norman Diamond
UUCP: {decvax|utzoo|ihnp4|allegra}!watmath!watdaisy!ndiamond
CSNET: ndiamond%watdaisy at waterloo.csnet
ARPA: ndiamond%watdaisy%waterloo.csnet at csnet-relay.arpa
"Opinions are those of the keyboard, and do not reflect on me or higher-ups."
More information about the Comp.lang.c
mailing list