<<< Direct Memory Operands | Index | Directives BYTE PTR, WORD PTR, DWORD PTR >>> |
The plus and index operators perform in exactly the same way when applied to direct memory operands.
For example, both the following statements move the second word value from a memory array into the AX register:
mov ax, array[ 2 ] mov ax, array + 2
The index operator can contain any direct memory operand. The following statements are equivalent:
mov ax, var mov ax, [var]
Many programmers prefer to enclose the operand in brackets to show that the contents, not the address, are used.
Memory operands in brackets make it easier to port code over to other assemblers.
The minus operator behaves as you would expect. Both the following instructions retrieve the value located at the word preceding array:
mov ax, array[-2] mov ax, array-2
<<< Direct Memory Operands | Index | Directives BYTE PTR, WORD PTR, DWORD PTR >>> |