[comp.arch] M88k byteorder selection

andrew@frip.gwd.tek.com (Andrew Klossner) (02/02/89)

[]

	"Some of our distributed filesystem people were BS'ing about
	this and the idea of making byte order a context dependent
	option in the OS came up."

This is done on the Motorola 88k, and described in the "binary
compatibility standard" (the precursor to the ABI).  Byte ordering is
controlled by a bit in the PSR.  A kernel system call is available for
the process to alter this bit, and it is part of the per-process
context.

On the 88k, instruction fetches are always big-endian (only data
fetch/store is controlled by the PSR bit), so a special magic number is
not needed.  A little-endian program begins by changing its byte-order
bit before doing any memory loads or stores.

The operating system requires that any parameters passed to it be in
big-endian order, so little-endian programs with lots of syscalls have
some extra work to do.  For programs like my (conceived but not yet
implemented) RT-11 emulator, the optimal thing to do is to run in
little-endian mode when performing PDP-11 instructions, and switch to
big-endian mode when handling RT-11 system calls.

  -=- Andrew Klossner   (uunet!tektronix!hammer!frip!andrew)    [UUCP]
                        (andrew%frip.gwd.tek.com@relay.cs.net)  [ARPA]