[comp.sys.ibm.pc.programmer] Memory models/Protected mode

harlow@plains.UUCP (Jay B. Harlow) (05/03/90)

In article <`43#%'=@rpi.edu> fargo@iear.arts.rpi.edu (Irwin M. Fargo) writes:
>Can anyone point me to any information (or perhaps an explanation) con-
>cerning the memory models a program can be compiled under?  I've heard little
>pieces here and there, but nothing that really explains it.
>
Memory Models for the x86 family are:
	TINY	- combined code & data, COM files
	SMALL	- 64K Code, 64K data,		near code ptrs, near data ptrs
	MEDIUM	- gtr 64K Code, 64K data,	far code ptrs, near data ptrs
	COMPACT	- 64K Code, gtr 64K data,	near code ptrs, far data ptrs
	LARGE	- gtr 64K Code, gtr 64K data,	far ptrs
	HUGE	- gtr 64K Code, gtr 64K data,	huge ptrs

near ptr	- 16 bit value offset into DGROUP or _TEXT(code seg)
far ptr		- segment:offset ptr, restricted to 64K item
huge		- segment:offset ptr, may be gtr 64K, 'special' support

the 386 in 32-bit protected mode is a 'special' case, normally it is
either a 32-bit TINY or a 32-bit SMALL mostly dos-extenders or Unix types
use this anyway....

Microsoft has a 'book' with there compiler kits (MASM 5.1,
an appendix in QC 2.0) on 'Mixed Language Programming Guide' that is Very
helpful in explaining the memory models & calling different 'Microsoft' 
languages & use of 'mixed' model programs ie: small model with far ptrs ;-)

>Also, can anyone point me to information on programming the protected mode
>of the 80286 and 80386?  I've heard that this information is very hard to
>find, so any well commented source code (if such exists) would be helpful.
>

two books I find invaluable on protected mode are:

	"Programming the 80386", Sybex
	Crawford & Gelsinger

	"Inside the 80286", Brady Books, Prentice Hall Press
	The Waite Group

the first book is the 'better' in that they include C-like code for 
every (mostall ;-)) instructions on the chip. so its what does a
LDT do, em, gee thats it... also other stuff like call through a 
CALL GATE, only has VERY little on the 286....

FLAME ON:   ;-)

also: TAB books (i mention this under protest ;-) has a book on the 
386 (don't remember the title, i find 'tab' books to be 'cheap'), that
included rather nicely commented assembler source for a Virtual-86 
'monitor' on a 386... shows whats need to be set up....

FLAME OFF:
			Jay
-- 
		Jay B. Harlow	<harlow@plains.nodak.edu>
	uunet!plains!harlow (UUCP)	harlow@plains (Bitnet)

Of course the above is personal opinion, And has no bearing on reality...

grimlok@hubcap.clemson.edu (Mike Percy) (05/04/90)

From article <4464@plains.UUCP>, by harlow@plains.UUCP (Jay B. Harlow):
> 
>>Also, can anyone point me to information on programming the protected mode
>>of the 80286 and 80386?  I've heard that this information is very hard to
>>find, so any well commented source code (if such exists) would be helpful.
>>
> 
> two books I find invaluable on protected mode are:
> 
> 	"Programming the 80386", Sybex
> 	Crawford & Gelsinger
> 
 
This book is probably the most useful 'instruction set list' book that I
have ever seen.  The inclusion of non-trivial examples (how about the
base for a 386 OS?), the level of information is excellent particularly
the description of tasks and OS level software considerations.
 
As a kicker, let me quote the authors from the introduction -
"Having spent years developing the chip itself, we are pleased to
present the _insider's view_ of how to program and use the 80386.
Throughout the book, we have strived to be accurate and authoritative,
as only the chip designers could be.