Files
2024-02-19 00:25:23 -05:00

57 lines
4.5 KiB
HTML

<html><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>80386 Programmer's Reference Manual -- Chapter 16</title>
</head>
<body>
<b>up:</b> <a href="TOC.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/TOC.HTM">Table of Contents</a><br>
<b>prev:</b> <a href="S15_07.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S15_07.HTM">15.7 Differences From 80286 Real-Address Mode</a><br>
<b>next:</b> <a href="S16_01.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S16_01.HTM">16.1 How the 80386 Implements 16-Bit and 32-Bit Features</a>
<p>
<hr>
<p>
<h1>Chapter 16 Mixing 16-Bit and 32 Bit Code</h1>
<p>The 80386 running in protected mode is a 32-bit microprocessor, but it is designed to support 16-bit processing at three levels:
<ol>
<li>Executing 8086/80286 16-bit programs efficiently with complete compatibility.
<li>Mixing 16-bit modules with 32-bit modules.
<li>Mixing 16-bit and 32-bit addresses and operands within one module.
</ol>
The first level of support for 16-bit programs has already been discussed in <a href="C13.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C13.HTM">Chapter 13</a>, <a href="C14.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C14.HTM">Chapter 14</a>, and <a href="C15.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C15.HTM">Chapter 15</a>. This chapter shows how 16-bit and 32-bit modules can cooperate with one another, and how one module can utilize both 16-bit and 32-bit operands and addressing.
<p>The 80386 functions most efficiently when it is possible to distinguish between pure 16-bit modules and pure 32-bit modules. A pure 16-bit module has these characteristics:
<ul>
<li>All segments occupy 64 Kilobytes or less.
<li>Data items are either 8 bits or 16 bits wide.
<li>Pointers to code and data have 16-bit offsets.
<li>Control is transferred only among 16-bit segments.
</ul>
A pure 32-bit module has these characteristics:
<ul>
<li>Segments may occupy more than 64 Kilobytes (zero bytes to 4 gigabytes).
<li>Data items are either 8 bits or 32 bits wide.
<li>Pointers to code and data have 32-bit offsets.
<li>Control is transferred only among 32-bit segments.
</ul>
Pure 16-bit modules do exist; they are the modules designed for 16-bit microprocessors. Pure 32-bit modules may exist in new programs designed explicitly for the 80386. However, as systems designers move applications from 16-bit processors to the 32-bit 80386, it will not always be possible to maintain these ideals of pure 16-bit or 32-bit modules. It may be expedient to execute old 16-bit modules in a new 32-bit environment without making source-code changes to the old modules if any of the following conditions is true:
<ul>
<li>Modules will be converted one-by-one from 16-bit environments to 32-bit environments.
<li>Older, 16-bit compilers and software-development tools will be utilized in the new32-bit operating environment until new 32-bit versions can be created.
<li>The source code of 16-bit modules is not available for modification.
<li>The specific data structures used by a given module inherently utilize 16-bit words.
<li>The native word size of the source language is 16 bits.
</ul>
On the 80386, 16-bit modules can be mixed with 32-bit modules. To design a system that mixes 16- and 32-bit code requires an understanding of the mechanisms that the 80386 uses to invoke and control its 32-bit and 16-bit features.
<p><a href="S16_01.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S16_01.HTM">16.1 How the 80386 Implements 16-Bit and 32-Bit Features</a><br>
<a href="S16_02.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S16_02.HTM">16.2 Mixing 32-Bit and 16-Bit Operations</a><br>
<a href="S16_03.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S16_03.HTM">16.3 Sharing Data Segments Among Mixed Code Segments</a><br>
<a href="S16_04.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S16_04.HTM">16.4 Transferring Control Among Mixed Code Segments</a>
<p>
<hr>
<p><b>up:</b> <a href="TOC.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/TOC.HTM">Table of Contents</a><br>
<b>prev:</b> <a href="S15_07.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S15_07.HTM">15.7 Differences From 80286 Real-Address Mode</a><br>
<b>next:</b> <a href="S16_01.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S16_01.HTM">16.1 How the 80386 Implements 16-Bit and 32-Bit Features</a>
</body>