Illegal use of register in indirect addressing

核能气质少年 提交于 2019-11-27 15:56:23
Aki Suihkonen

The original 8086 addressing modes are limited to the combinations in this chart:

     (disp)   (base)   (offset)
 mov [1234] + [bx]  +  [si], ax
              [bp]  +  [di]

One must choose maximum of one item from each group (displacement, base and offset). No other combination is valid.

The 80386 addressing modes were extended towards more orthogonal:

 mov  al, byte ptr [12345] + [esp + 8 * eax];

Here the index registers are all 32-bit, esp can be used to point directly to stack variables, and the scaling term has legal values of 1,2,4 and 8. With this many combinations the instruction LEA can be used to perform a single instruction orthogonal 3-parameter addition without changing flags: [reg1] = [reg2] + [reg3]; and to perform some other arithmetic, such as multiplying register by a factor of 3,5 or 9.

Without 32-bit addressing modes one has to emulate the scaling e.g. with

     mov bx, (N-1)*2          // constant expression
 a:  mov ax, [bx + di]
     adc ax, [bx + si]
     sub bx, 2
     jns a

See also purpose of LEA instruction.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!