The memory addressing general form (found it here) is:
[base + index*scale + disp]
So a correct instruction would be something like:
mov eax, [ebx + ecx*4 + 2]
And this instruction should be incorrect (but NASM found it to be correct!):
mov eax, [ebx + ecx + 123 + 5 - 2]
So why is this instruction correct (even though it does not conform to the memory addressing general form)?
I think it is correct because:
123 + 5 - 2
are all considered to be one number (126
) representingdisp
.- The documentation says: "If no scale is specified, scale is taken to be 1" (so
ecx
is effectively:ecx*1
). - So the final result is:
mov eax, [ebx + ecx*1 + 126]
.
Am I correct?