background image

Vol. 3B 20-1

CHAPTER 20

8086 EMULATION

IA-32 processors (beginning with the Intel386 processor) provide two ways to execute new or legacy programs 
that are assembled and/or compiled to run on an Intel 8086 processor: 

Real-address mode.

Virtual-8086 mode.

Figure 2-3 shows the relationship of these operating modes to protected mode and system management mode 
(SMM). 
When the processor is powered up or reset, it is placed in the real-address mode. This operating mode almost 
exactly duplicates the execution environment of the Intel 8086 processor, with some extensions. Virtually any 
program assembled and/or compiled to run on an Intel 8086 processor will run on an IA-32 processor in this mode.
When running in protected mode, the processor can be switched to virtual-8086 mode to run 8086 programs. This 
mode also duplicates the execution environment of the Intel 8086 processor, with extensions. In virtual-8086 
mode, an 8086 program runs as a separate protected-mode task. Legacy 8086 programs are thus able to run 
under an operating system (such as Microsoft Windows*) that takes advantage of protected mode and to use 
protected-mode facilities, such as the protected-mode interrupt- and exception-handling facilities. Protected-mode 
multitasking permits multiple virtual-8086 mode tasks (with each task running a separate 8086 program) to be run 
on the processor along with other non-virtual-8086 mode tasks.
This section describes both the basic real-address mode execution environment and the virtual-8086-mode execu-
tion environment, available on the IA-32 processors beginning with the Intel386 processor. 

20.1 REAL-ADDRESS 

MODE

The IA-32 architecture’s real-address mode runs programs written for the Intel 8086, Intel 8088, Intel 80186, and 
Intel 80188 processors, or for the real-address mode of the Intel 286, Intel386, Intel486, Pentium, P6 family, 
Pentium 4, and Intel Xeon processors.
The execution environment of the processor in real-address mode is designed to duplicate the execution environ-
ment of the Intel 8086 processor. To an 8086 program, a processor operating in real-address mode behaves like a 
high-speed 8086 processor. The principal features of this architecture are defined in Chapter 3, “Basic Execution 
Environment”, of
 the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1.
The following is a summary of the core features of the real-address mode execution environment as would be seen 
by a program written for the 8086:

The processor supports a nominal 1-MByte physical address space (see Section 20.1.1, “Address Translation in 
Real-Address Mode”, for spec
ific details). This address space is divided into segments, each of which can be up 
to 64 KBytes in length. The base of a segment is specified with a 16-bit segment selector, which is zero 
extended to form a 20-bit offset from address 0 in the address space. An operand within a segment is 
addressed with a 16-bit offset from the base of the segment. A physical address is thus formed by adding the 
offset to the 20-bit segment base (see Section 20.1.1, “Address Translation in Real-Address Mode”).

All operands in “native 8086 code” are 8-bit or 16-bit values. (Operand size override prefixes can be used to 
access 32-bit operands.)

Eight 16-bit general-purpose registers are provided: AX, BX, CX, DX, SP, BP, SI, and DI. The extended 32 bit 
registers (EAX, EBX, ECX, EDX, ESP, EBP, ESI, and EDI) are accessible to programs that explicitly perform a size 
override operation.

Four segment registers are provided: CS, DS, SS, and ES. (The FS and GS registers are accessible to programs 
that explicitly access them.) The CS register contains the segment selector for the code segment; the DS and 
ES registers contain segment selectors for data segments; and the SS register contains the segment selector 
for the stack segment.

The 8086 16-bit instruction pointer (IP) is mapped to the lower 16-bits of the EIP register. Note this register is 
a 32-bit register and unintentional address wrapping may occur.