I'm having trouble understanding the difference between the two, the following example really had me puzzled:
section .data
msg: db "Thank you"
var: dd 0x31323334
len equ msg-4
section .text
global main
main:
mov eax, 4
mov ebx, 1
mov ecx, msg
mov edx, var-len
section .data
%define len msg-4
msg: db "Thank you"
var: dd 0x31323334
section .text
global main
main:
mov eax, 4
mov ebx, 1
mov ecx, msg
mov edx, var-len
The first program prints "Thank you4321", which is quite obvious, but for some reason the second program prints "Thank"
I've tried tracking the values and I got : var = 0x2011, msg = 0x2008, len = 0x2004
, but somehow edx
got 0x05
where I would think it'd be 0x2011-0x2004 = 0x0D
Any idea why this is?
Another thing I noticed with equ is that if I calculate len-var
I get 0 , my guess is that it has no address in memory because it's a macro? Is this correct? Thanks in advance.