inter80386

SEGMENT REGISTER

.

~ BASE REGISTER

 

SS

GS

FS

ES

DS

+ !+-____-IDISPLACEMENT

 

(IN INSTRUCTION)

 

 

EFFECTIVE

SEGMENT

 

ADDR ESS

 

LIMIT

 

 

 

 

/

 

LINEAR

 

DESCRIPTOR REGISTERS

ADDRESS TARGET ADDRESS

 

SELECTED

SEGMENT

ACCESS RIGHTS CS

LIMIT

BASE ADDRESS------

~

SEGMENT BASE ADDRESS

231630-51

Figure 2-9. Addressing Mode Calculations

2.5.4Differences Between 16 and 32 Bit Addresses

In order to provide software compatibility with the 80286 and the 8086, the 80386 can execute 16-bit instructions in Real and Protected Modes. The proc- essor determines the size of the instructions it is ex- ecuting by examining the°D bit in the CS segment Descriptor. If the D bit is then all operand lengths and effective addresses are assumed to be 16 bits long. If the D bit is 1 then the default length for oper- ands and addresses is 32 bits. In Real Mode the default size for operands and addresses is 16-bits.

Regardless of the default precision of the operands or addresses, the 80386 is able to execute either 16 or 32-bit instructions. This is specified via the use of override prefixes. Two prefixes, the Operand Size Prefix and the Address Length Prefix, override the value of the D bit on an individual instruction basis. These prefixes are automatically added by Intel as- semblers.

Example: The processor is executing in Real Mode and the programmer needs to access the EAX regis- ters. The assembler code for this might be MOV EAX, 32bitMEMORYOP, ASM 386 automatically de- termines that an Operand Size Prefix is needed and generates it.

Example: The D bit is 0, and the programmer wishes to use Scaled Index addressing mode to access an array. The Address Length Prefix allows the use of MOV DX, TABLE[ESI*2]. The assembler uses an Address Length Prefix since, with D = 0, the default addressing mode is 16-bits.

Example: The D bit is 1, and the program wants to store a 16-bit quantity. The Operand Length Prefix is used to specify only a 16-bit value; MOV MEM16, DX.

18

Page 79
Image 79
Intel 80386 manual Differences Between 16 and 32 Bit Addresses, Addressing Mode Calculations