[comp.os.minix] ibm process size

mjs@cbnewsl.ATT.COM (michael.j.scheutzow) (02/18/89)

>  the 8088, 8086,80186, 80286 totally lack the ability to address beyond 64KB.
>  There simply is no such machine operation.

This is extremely misleading.  The Intel architecture uses "segments", and
although each segment is limited to 64Kb, a single program can have as many as
it wants.  The hardware directly supports separate segments for code, data and
stack.  This means (in theory) that minix processes could be as large as 192Kb
without having to resort to far pointers.

The problem with theory, of course, is that it makes life hard for c-compiler
writers.  The easiest compiler to implement essentially ignores this segment
hardware by dumping the code, data and stack into one 64Kb area (guess which
approach is used by the pc-minix v1.2 compiler?)

The next best thing to do is assign the code to one segment and the data+stack
to a second segment.  AST says that minix supports this configuration, if you
can find a compiler (and libraries) that generate it!  This type of program can
be as large as 128Kb, and I find it considerably less restrictive than what
we are currently using.

>  the .exe format allows for text, data, or both to exceed 64K, by finishing
>  the relocation to physical address when the program is loaded.  This is
>  the same idea as the ATARI ST uses when it loads.

Text and data can only exceed 64K if they are in multiple segments.  The
segment addresses are assigned at load time; it's unlikely to be the same
approach used by a M680x0 machine.

> The bottom line is that:
> A. ...
> B. A program can exceed 64 K only by using the Microsoft extensions.
>    A MINIX would need to create Microsoft C 5.1 to have a CC command.

Obviously untrue.

Cheers,
Mike S.
att!cbnewsl!mjs

jds@mimsy.UUCP (James da Silva) (02/19/89)

In article <134@cbnewsl.ATT.COM> mjs@cbnewsl.ATT.COM (michael.j.scheutzow) writes:
>....  The hardware directly supports separate segments for code, data and
>stack.  This means (in theory) that minix processes could be as large as 192Kb
>without having to resort to far pointers.

Don't forget ES, the `Extra Segment' register!  This gives us 256k without
far pointers, in theory.  This isn't practical, however.  C doesn't
distinguish between the stack and data `segments'; all data must be in the
same address space.  The same code must be able to handle being passed the
address of a local variable (in the stack), and a global one (in the `data
segment').  How can the code tell which segment to access?  So, 64k code
plus 64k data/stack is the practical limit for 8086 `small' model.

>The problem with theory, of course, is that it makes life hard for c-compiler
>writers.  The easiest compiler to implement essentially ignores this segment
>hardware by dumping the code, data and stack into one 64Kb area (guess which
>approach is used by the pc-minix v1.2 compiler?)
>
>The next best thing to do is assign the code to one segment and the data+stack
>to a second segment.  AST says that minix supports this configuration, if you
>can find a compiler (and libraries) that generate it!  This type of program
>can be as large as 128Kb, and I find it considerably less restrictive than
>what we are currently using.

Then you will be happy to know that the Minix assembler DOES support split
I&D, as of Minix 1.2, with the `-i' flag.  The compiler (and thus the
libraries) doesn't care, as it generates assembler code that looks
something like this:

	.code
_func:
	<some code here>
	.data
_datum:
	<some data here>
	...

It never counts on particular addresses for data or code.  All near jumps
and calls are relative to the CS register, data accesses relative to
the DS register.  The SS register (stack) is used for local vars and by the
hardware for CALLs and RETs.

The upshot is that the compiler doesn't care whether CS == DS at runtime
(the assembler cares).  It does require that DS == SS, as the offets of
local stack variables have to be reachable with DS.  

Everyone who is confused should go read Appendix B of The Minix Book.  This
is a good quickie intro to the 8086 and PC architecture.  There is one
error related to this discussion, however.  On page 368 Andy writes:

    "In all cases, the address computed by adding the contents of BP to
    a constant is relative to DS (which is always equal to SS in MINIX)."

This is backwards.  BP-indexed addressing is relative to SS, which happens
to equal DS in MINIX.  Yes, I'm nit-picking.

Jaime
...........................................................................
: domain: jds@mimsy.umd.edu				     James da Silva
: path:   uunet!mimsy!jds