Hi Rob,
This is over my head, but fools rush in...
My first take on this was that nothing is being "overridden" - the first "local label" is actually "function1.myvar1", and the second one "function2.myvar1", Nasm allows us to refer to each by its "nickname" within its scope...
However, after fooling with it a bit, I have come to believe that the "local label" mechanism isn't involved at all here. Since ".myvar1" isn't actually a label, it isn't "local". Try it with "myvar1" without the '.' - still works! It's just a plain "%define". It surprises me a bit that we can redefine something without "%undef"ing it first (this is what I've been doing). However, this is documented (section 4.1.1):
This doesn't prevent single-line macros being redefined: you can perfectly well define a macro with
%define foo bar
and then re-define it later in the same source file with
%define foo baz
So I guess you can do it safely.
FWIW, I prefer to do the "%define"s without the "[]"s, and write:
mov eax, [.myvar1]
lea eax, [.myvar1]
rather than:
mov eax, .myvar1
lea eax, .myvar1
just to preserve the usual "[contents]" syntax - without it, it "looks like" an immediate, to me. I like using the '.', since it looks like the usual "local"... even though it apparently isn't (Gaz's old macros did it this way).
So I think you're "safe" to do it, even though it isn't really a "local label". Better, actually, since a "non-local" label won't "break the scope"...
function1:
%define .myvar1 ebp + 8
cmp al, '9'
jbe skip
add al, 7
skip:
mov eax, [.myvar1]
wouldn't work if it were a real "local label".
Hope someone who actually understands how this works will comment, but I think you're okay.
Best,
Frank