8086 assembly language learning (e) addressing 8086

8086 assembly memory addressing

  Previous blog are referred to the 8086 compilation of how much memory addressing, such as mov ax [2345H]. The 8086 assembly also provides additional, more flexible addressing modes to meet various needs.

  It is emphasized that, regardless of the addressing mode, the address of the memory is always addressable by a combination of base address + offset address (base + offset period) is made except that the base address and the offset address should where can I get .

8086 assembly provides addressing mode segment base

  In an mov ax [2345H], the value indicates the segment address is not shown, since 8086 when the compilation process is not explicitly segment base instructions, the default value of the data segment register DS as the segment base . In other words, mov AX [2345H] actually mov ax ds: [2345H] abbreviations.

  In 8086 assembly by: when the designated segment base address "offset address segment register" approach. But not the only ds segment register, the memory address when the address segment may not be stored in the segment register DS, but other storage segment register. Can be explicitly specified (in the instructions mov ax cs: [2345H] At this time, the segment address of the code segment register cs ).

8086 assembly provides addressing offset manner

  8086 assembly providing an offset address many ways like, can be divided into five categories: direct addressing, register indirect addressing, register relative addressing, indexed addressing base, relative base indexed addressing, according to the order , increasing flexibility and complexity .

  Offset address may be designated by a register, may be stored in one place in memory, or in the instruction buffer, or also consists of a combination thereof .

Direct addressing

  Direct addressing the previously mentioned fact, addressing (mov ax [2345H]), it specifies the address offset address stored directly in the instruction, in actual operation, CPU execution from the instruction buffer to obtain the offset value corresponding to memory addressing.

  A number proposed here idata (immediate data) directly, the concept of the immediate, or to refer to a constant value 2345H 1000H such instructions. Command idata containing constants, which values ​​are stored in the instruction buffer, acquires, when executed by the CPU.

  Instruction MOV ax, 1000H , 1000H into immediate representative of the ax can be abstracted as mov ax, idata form.

  Instruction mov ax, [1000H], representative DS: 1000H memory addressing can be abstracted as mov ax, [idata] form.

Register indirect addressing

  Register indirect addressing, the addressing mode can be obtained from the name, the address is not a constant but a similar variable, whose value is present in a particular register class, find value in the register.

  Note that the 8086 does not allow all the registers of the register indirect addressing with, and only the register bx, bp, si, di four registers is referred to hunt value register, register indirect addressing can be used. Other registers are used when the register indirect addressing is considered compiler syntax error.

  A register indirect addressing mode is [bx] / [bp] / [si] / [di] four kinds, e.g. mov ax, [bx], meaning the instruction is the memory address ds: bx data into at in register ax.

Register relative addressing

  Can be specified by a particular type or idata constant offset address register addressing, direct addressing and indirect addressing registers of a register or use only one element in the immediate idata, is relatively simple. The addressing is more complex and the constant register addressing idata combination achieved.

  Register relative addressing register is addressed by combining with idata performed. Such a relative address register + register addressing a constant addressing mode, bx / bp / si / di equivalent.

 Register relative addressing more flexible, roughly the following (the first type is the standard format, 2,3,4 syntactic sugar):

  1. [bx + idata] / [bp + idata] / [si + idata] / [di + idata] standard formality

  2. [bx] .idata / [bp] .idata / [si] .idata / [di] .idata for general structure

  3.idata [bx] / idata [bp] / idata [si] / idata [di] generally used for one-dimensional arrays

  4. [bx] [idata] /    [bp] [idata] / [si] [idata] / [di] [idata] generally used for two-dimensional array  

  Why 8086 will provide a compilation of so many different syntax, but it is essentially the same syntactic sugar for the register relative addressing? Careful observation can be found, much like the structure of 2,3,4 writing high-level language / objects, access an array of ways. 8086 offers a variety of syntax that allows programs written easier to understand. 8086 assembly subsequent blog will simulate an array of high-level language, memory design structure described in detail.

Yl indexed addressing

  Yl indexed addressing is more flexible than the relative addressing mode register, it is a combination of two different addressable register. But here bx / bp / si / di pairwise and not freely mix, wherein bx / bp group, si / di group. Addressable register in order between different combinations of two groups, there are four: [BX + Si], [BX + DI], [BP + Si], [BP + DI].

     Yl indexed addressing is generally used for addressing data in a two-dimensional array.

Relative base indexed addressing

  Indexed addressing relative yl group basis on indexed addressing, and then add a constant idata element addressing mode is a two variable + constant , is the most complex and flexible one addressing mode.

  Group and the like addressing indexed addressing, indexed addressing relative base has four ways: [BX + Si + Idata], [BX + Si + Idata], [BX + Si + Idata], [BX + si + idata].

  Relative base indexed addressing mode 8086CPU provided to provide a convenient process for the nested structure data, can compare the natural expression of the array access The offset address when the structural body.

Guess you like

Origin www.cnblogs.com/xiaoxiongcanguan/p/12397645.html