An expression such as myString+1 produces what is called an effective address by adding a constant to the variable's offset. |
|
mov al, [myString+1] mov al, myString+1
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 AL register. |
|
al = [X+1] |
ax = [X+1] |
ax = [X+1] |
---|---|---|
.data X WORD 10h, 20h, 30h .code mov eax, 0 mov al, X+1 call WriteHex |
.data X WORD 10h, 20h, 30h .code mov eax, 0 mov ax, X+1 call WriteHex |
.data X WORD 10h, 20h, 30h .code mov eax, 0 mov ebx, offset X mov ax, [ebx+1] call WriteHex |
Output | Output | Output |