Chapter 16 mixing 16-bit and 32-bit code – Intel IA-32 User Manual

Page 581

Advertising
background image

Vol. 3A 16-1

CHAPTER 16

MIXING 16-BIT AND 32-BIT CODE

Program modules written to run on IA-32 processors can be either 16-bit modules or 32-bit
modules. Table 16-1 shows the characteristic of 16-bit and 32-bit modules.

The IA-32 processors function most efficiently when executing 32-bit program modules. They
can, however, also execute 16-bit program modules, in any of the following ways:

In real-address mode.

In virtual-8086 mode.

System management mode (SMM).

As a protected-mode task, when the code, data, and stack segments for the task are all
configured as a 16-bit segments.

By integrating 16-bit and 32-bit segments into a single protected-mode task.

By integrating 16-bit operations into 32-bit code segments.

Real-address mode, virtual-8086 mode, and SMM are native 16-bit modes. A legacy program
assembled and/or compiled to run on an Intel 8086 or Intel 286 processor should run in real-
address mode or virtual-8086 mode without modification. Sixteen-bit program modules can also
be written to run in real-address mode for handling system initialization or to run in SMM for
handling system management functions. See Chapter 15, “8086 Emulation,” for detailed infor-
mation on real-address mode and virtual-8086 mode; see Chapter 24, “System Management,”
for information on SMM.

This chapter describes how to integrate 16-bit program modules with 32-bit program modules
when operating in protected mode and how to mix 16-bit and 32-bit code within 32-bit code
segments.

Table 16-1. Characteristics of 16-Bit and 32-Bit Program Modules

Characteristic

16-Bit Program Modules

32-Bit Program Modules

Segment Size

0 to 64 KBytes

0 to 4 GBytes

Operand Sizes

8 bits and 16 bits

8 bits and 32 bits

Pointer Offset Size (Address Size)

16 bits

32 bits

Stack Pointer Size

16 Bits

32 Bits

Control Transfers Allowed to Code
Segments of This Size

16 Bits

32 Bits

Advertising