section .data
var dd 10
section .text
add [var] , eax
for above code nasm gives error operation size not specified,
but if we reverse it add eax, [var]
it doesn't gives error.
why error for only first and not for second type ?
section .data
var dd 10
section .text
add [var] , eax
for above code nasm gives error operation size not specified,
but if we reverse it add eax, [var]
it doesn't gives error.
why error for only first and not for second type ?
You need specify size like this:
add dword [var],eax
Because the first operand is the destination operand and needs to be a register so instead just move it back :
add eax, [var]
mov [var], eax