80386 processor's addressing mode In form, the maximum addressing space of the 80386 processor is still 1M, and 8086/8088 is similar. That is, the offset address in the 10h segment is formed to form a 20-bit address. In this mode, the segment base is a multiple of 16, and the length is up to 64K. In protection mode, the 80386 processor can use all physical memory. The segment base can be 32 bits, or may not be 16 times, and its maximum length is 4G, which is completely different from 8086, and uses the segment base address directly to the block at the end of the segment, but not Segment base address is left 4 bits (multiplied by 16). Normally, in addition to accessing the stack, the default segment is DS, and there is a cross-bouquet prefix. When BP, EBP, ESP is used as the radical register, the default segment register should be SS, and a few simple examples: MOV EAX, [Si]; the segment register here is DS MOV EAX, FS: [ESI ]; The segment register here is FS because the command is used in the command to specify MOV Eax, [BP]; the segment register here is SS because the BP is used as the base register MOV EAX, GS: [BP The segment register is GS, because the order in which the cross-segment prefix is used in the instruction to display the operation of the 32-bit number of 80386 is "high and low", ie, high 16- "high 16, high 8-" high 8 , Low 16- "low 16, low 8-" low 8, which is similar to 8086. At the same time, 80386 microprocessor is compatible with all 8086 addressing methods, and there is a big improvement and extension of the 8086 addressing mode. Under 8086, only BP, BX, Si, DI is allowed to be a address register, but under 80386, 8 universal registers can be used as a address register. However, it should be noted that in the base address register addressing method or relative base address address address, the segment register is determined by the base register, rather than being determined by the index register, while other ESPs The seven general registers can be used as an index register, with code is: MOV EAX, [EBP ESP 2]; this instruction is wrong because it is not possible to use ESP as an indeached register MOV EAX, [EBP ESI 10H]; segment registers here should have a base register to determine. The base register is BP, then the paragraphs here are SS MOV Eax, GS: [EBP EDI 100H]; don't look, the segment registers here should be GS because the instructions are displayed by the cross-block prefix to display 80386 support. The base site inter-transmissive addressing further satisfies the data type supported by advanced languages. For C language, ordinary variables, arrays, structures, structural arrays, arrays of arrays we can store both in the stack (static definition -static definition), or in the heap (Dynamic Definition - Dynamic Definition ), Can be implemented using ASM. The base address register provides two parts that can be changed, and the displacement is static.
Looking down below: // variables in c programming-language, the corresponding asm will list below void main () {Int a; // Normal variable, use the ASM addressing DS: [one shift], such as DS: [2000], belongs to the direct addressing method Int arch [24]; // array, use DS: [BX Si * 4], 4 to represent the length of the base address with the ASM addressing Site mode Struct ABC {INT A, B, C; Float D;}; Struct ABC AA; / / Structural, DS: [BX Shift], Shift represents the relative address of the register when adding by ASM addressing. Struct ABC AA [100]; // Structural array, uses DS: [BX Si * SizeOf (ABC) Shift] with ASM, belongs to the relative base address Addressing mode Struct CDE {Int Array [100 ]; Float E, F, G;}; Struct CDE CCC; // array structure, use DS: [BX Si * 4 Shift] with ASM Addressing, belongs to the relative base address Addressing method} 80386 Almost exactly the same as 8086's addressing mode, only 80386's addressing mode is more flexible, and its operand has 32, 16-bit, 8 bits. Let's take a revision of the 8086 addressing method: a. Immediate addressing, the so-called immediate addressing is in the instruction, such as: MOV AX, 5678H b. Direct addressing, that is, the number of operands Address EA, such as MOV AX, [1234] c. Register address addressing, with the content of the register as a valid address of the operand, such as Si = 1234, MOV AX, [Si], 8086, available registers available only 4: BX, BP, Si, Di, 80386 8 universal registers can be used. D. The register is relatively addressed, i.e., on the basis of register address addressing, the displacement amount can be 8 bits or 16 bits, such as MOV AX, [BX 90H]. E. Extracy address address, that is, the effective address of the operand is generated by an entry register and an indeached register, such as MOV AX, [BX Si]. So under 8086, only Si, DI can be used as an index register, other seven general registers other than ESP outside 80386 can be used as an index register, such as MOV AX, [BX Si]. F. Relative base address address, add one shift on the basis of the E address, such as MOV AX, [BX Si 100H]. Under 8086, we often add pseudo-instruction Word PTR or Byte Ptr.