[comp.lang.c] 64 bit architectures and C

Kai_Henningsen@ms.maus.de (Kai Henningsen) (05/03/91)

Marco S Hyman marc%dumbcat.sf.ca.us @ SUB schrieb am 28.04.1991, 16:33

MS>I hope not -- at least not without some other way of describing a 16-bit
MS>value.  64-bit architecture machines will still have to communicate with
MS>machines that do support 16-bit values.  Swapping bytes between big and
MS>endian machines is bad enough. Think about the overhead of converting a pair
MS>of bytes to a 16-bit value.

Well, use either text or some other machine-independant format. As the name
says, machine-dependant data formats are no good for communication between
heterogenous machines. They never will be. Suppose a machine with 36-bit words
(there are) ...

MS>Hmmm.  How would such a processor communicate with hardware devices
MS>16-bit I/O?  How would a structure that maps an external device's registers
MS>coded if the registers are 16-bits wide?  If there is a way to do these
MS>then a 16-bit wide data type is probably necessary.

Such a processor would deal with such hardware the same way a PC deals with
hardware needing 4- or 12-bit data.

MfG Kai

Kai_Henningsen@ms.maus.de (Kai Henningsen) (05/07/91)

Larry Campbell campbell @ redsox.bsw.com schrieb am 29.04.1991, 10:55

LC>        void *  128 bits
LC>
LC>Thank *god* it has a fully-compliant ANSI compiler.
LC>
LC>For extra credit:  can you guess what machine this is?

My god - 16 byte addresses?! What is that for a beast?!

MfG Kai

Kai_Henningsen@ms.maus.de (Kai Henningsen) (05/07/91)

warren.a.montgomery warren @ cbnewsh.att.com schrieb am 29.04.1991, 12:02

ww>There are lots of ways a programmer may want to declare an integer:
ww>
ww>1       Any convenient and reasonable size.
ww>
ww>2       Any convenient size large enough to represent X.
ww>
ww>3       The smallest convenient size large enough to represent X.
ww>
ww>4       Exactly Y bits or bytes long.
ww>
ww>5       Exactly the same size as datatype Z

ww>but these will do for a start.  How are things like this best
ww>expressed in C or C++?  Do other languages provide better overall solutions?

Well, I'd say there is only one way, if you program for portability.

First, use int (and char) for (1).

Second, whenever you need something else, typedef (in a central header file) a
type for it, using a good-to-remember name, AND COMMENT WHAT EXACTLY YOU TRY TO
DO at the same place, so the guy doing the port will know what to substitute.

Try not to rely on external data formats, but if you do, encapsulate
transitions between internal and external representations (even if identical)
in functions, AND MARK THEM CLEARLY, so the porter will know where to look in
case of odd-sized ints or different byte sex.

And while we're at it, DON'T ASSUME YOU HAVE ASCII!


As for other solutions, the one I use somewhat often is Pascal. There, you can
specify exactly which values you expect to store in a type, that is, you can
define a type for month values like this:

TYPE Month = 1 .. 12;

This adds the added benefit that the compiler can check that you really use
only those values, thus catching those annoying bugs ...

On the other hand, for packing, you can only tell the compiler that you want
him to pack this data structure - not how to do it. Bit fields are somewhat
better ...

MfG Kai

Kai_Henningsen@ms.maus.de (Kai Henningsen) (05/08/91)

Marco S Hyman marc%dumbcat.sf.ca.us @ SUB schrieb am 04.05.1991, 15:36

MS>In article <226@tdatirv.UUCP> sarima@tdatirv.UUCP (Stanley Friesen) writes:
MS> > Binary communication between machines should use XDR *not* C structures.
MS>
MS>Agreed.  (But please, not ASN.1/BER as someone else suggested :-)

Why that? I might need to do something like that soon, so I'm interested in
your reasons.
If they are not of general interest, my EMail address is

kh@ms.maus.de

MfG Kai

gwyn@smoke.brl.mil (Doug Gwyn) (05/11/91)

In article <15073@ms.maus.de> Kai_Henningsen@ms.maus.de (Kai Henningsen) writes:
>LC>        void *  128 bits
>My god - 16 byte addresses?! What is that for a beast?!

It takes 32 bits just to specify the Internet address portion of the
object's capability.

(I invented the model behind that statement, but if you understand
what I'm talking about you should also be able to agree that it would
be a useful implementation, if one could pull it off.)