⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmodels.gml

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 GML
📖 第 1 页 / 共 2 页
字号:
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
:set symbol="function"  value="function".
:set symbol="functions" value="functions".
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
:set symbol="function"  value="subprogram".
:set symbol="functions" value="subprograms".
.do end
.*
.chap *refid=mdl86 16-bit Memory Models
.*
.if &e'&dohelp eq 0 .do begin
.section Introduction
.do end
.*
.np
.ix 'memory models' '16-bit'
This chapter describes the various 16-bit memory models supported by
&cmpname..
Each memory model is distinguished by two properties; the code model
used to implement &function calls and the data model used to reference
data.
.*
.section 16-bit Code Models
.*
.np
There are two code models;
.autopoint
.point
the small code model and
.point
the big code model.
.endpoint
.pc
.ix 'small code model'
.ix 'code models' 'small'
.ix 'near call'
A small code model is one in which all calls to &functions are made
with
.us near calls.
In a near call, the destination address is 16 bits and is relative to
the segment value in segment register CS.
Hence, in a small code model, all code comprising your program,
including library &functions, must be less than 64K.
.if '&lang' eq 'FORTRAN 77' .do begin
&cmpname does not support the small code model.
.do end
.np
.ix 'big code model'
.ix 'code models' 'big'
.ix 'far call'
A big code model is one in which all calls to &functions are made with
.us far calls.
In a far call, the destination address is 32 bits (a segment value and
an offset relative to the segment value).
This model allows the size of the code comprising your program to
exceed 64K.
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.remark
If your program contains less than 64K of code, you should use a memory
model that employs the small code model.
This will result in smaller and faster code since near calls are
smaller instructions and are processed faster by the CPU.
.eremark
.do end
.*
.section 16-bit Data Models
.*
.np
There are three data models;
.autopoint
.point
the small data model,
.point
the big data model and
.point
the huge data model.
.endpoint
.pc
.ix 'small data model'
.ix 'data models' 'small'
A small data model is one in which all references to data are made
with
.us near pointers.
Near pointers are 16 bits; all data references are made relative to
the segment value in segment register DS.
Hence, in a small data model, all data comprising your program must be
less than 64K.
.np
.ix 'big data model'
.ix 'data models' 'big'
A big data model is one in which all references to data are made with
.us far pointers.
Far pointers are 32 bits (a segment value and an offset relative to
the segment value).
This removes the 64K limitation on data size imposed by the small data
model.
However, when a far pointer is incremented, only the offset is
adjusted.
&cmpname assumes that the offset portion of a far pointer will not be
incremented beyond 64K.
The compiler will assign an object to a new segment if the grouping of
data in a segment will cause the object to cross a segment boundary.
Implicit in this is the requirement that no individual object exceed
64K bytes.
For example, an array containing 40,000 integers does not fit into
the big data model.
An object such as this should be described as
.us huge.
.np
.ix 'huge data model'
.ix 'data models' 'huge'
A huge data model is one in which all references to data are made
with far pointers.
This is similar to the big data model.
However, in the huge data model, incrementing a far pointer will
adjust the offset
.us and
the segment if necessary.
The limit on the size of an object pointed to by a far pointer
imposed by the big data model is removed in the huge data model.
.autonote Notes:
.if '&lang' eq 'FORTRAN 77' .do begin
.note
The huge data model has the same characteristics as the big data
model, but formal array arguments are assumed to exceed 64K bytes.
You should use the huge data model whenever any arrays in your
application exceed 64K bytes in size.
.do end
.note
If your program contains less than 64K of data, you should use the
small data model.
This will result in smaller and faster code since references using
near pointers produce fewer instructions.
.note
The huge data model should be used only if needed.
The code generated in the huge data model is not very efficient since
a run-time routine is called in order to increment far pointers.
This increases the size of the code significantly and increases
execution time.
.endnote
.*
.section Summary of 16-bit Memory Models
.*
.np
As previously mentioned, a memory model is a combination of a code
model and a data model.
The following table describes the memory models supported by
&cmpname..
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.ix 'tiny memory model'
.ix 'memory models' 'tiny'
.ix 'small memory model'
.ix 'memory models' 'small'
.ix 'compact memory model'
.ix 'memory models' 'compact'
.do end
.ix 'medium memory model'
.ix 'memory models' 'medium'
.ix 'large memory model'
.ix 'memory models' 'large'
.ix 'huge memory model'
.ix 'memory models' 'huge'
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.millust begin
Memory      Code        Data        Default     Default
Model       Model       Model       Code        Data
                                    Pointer     Pointer
--------    --------    --------    --------    --------
tiny        small       small       near        near
small       small       small       near        near
medium      big         small       far         near
compact     small       big         near        far
large       big         big         far         far
huge        big         huge        far         huge
.millust end
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.millust begin
Memory      Code        Data        Default     Default
Model       Model       Model       Code        Data
                                    Pointer     Pointer
--------    --------    --------    --------    --------
medium      big         small       far         near
large       big         big         far         far
huge        big         huge        far         huge
.millust end
.do end
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.if '&target' ne 'QNX' .do begin
.*
.section Tiny Memory Model
.*
.np
.ix 'memory models' 'tiny'
In the tiny memory model, the application's code and data must total
less than 64K bytes in size.
All code and data are placed in the same segment.
Use of the tiny memory model allows the creation of a COM file for
the executable program instead of an EXE file.
For more information, see the section entitled
"Creating a Tiny Memory Model Application" in this chapter.
.do end
.do end
.*
.section Mixed 16-bit Memory Model
.*
.np
.ix 'mixed memory model'
.ix 'memory models' 'mixed'
A mixed memory model application combines elements from the various
code and data models.
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
A mixed memory model application might be characterized as one that
uses the
.kw near,
.kw far,
or
.kw huge
keywords when describing some of its &functions or data objects.
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
A mixed memory model application might be characterized as one that
includes arrays which are larger than 64K bytes.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -