| To create a direct-offset operand, add a displacement to the name of a variable. An expression such as produces what is called an effective address by adding a constant to the variable’s offset. |
|
| The brackets (dereferencing) are not required, i.e., the two commands are equal: |
|
|
Range Checking
MASM has no built-in range checking for effective addresses. The code on the right does not put any letter in the string to the register: |
|
al = [X+1]
|
ax = [X+1]
|
ax = [X+1]
|
INCLUDE Irvine32.inc .data X WORD 10h, 20h, 30h .code main PROC mov eax, 0 mov al, X+1 call WriteHex exit main ENDP END main |
INCLUDE Irvine32.inc .data X WORD 10h, 20h, 30h .code main PROC mov eax, 0 mov ax, X+1 call WriteHex exit main ENDP END main |
INCLUDE Irvine32.inc .data X WORD 10h, 20h, 30h .code main PROC mov eax, 0 mov ebx, offset X mov ax, [ebx+1] call WriteHex exit main ENDP END main |
| Output | Output | Output |
|
“I’m not arguing, I’m just explaining why I’m right.” ― Unknown |