The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Gil on March 18, 2005, 05:00:41 PM

Title: Can't jmp into proc
Post by: Gil on March 18, 2005, 05:00:41 PM
Hi To all
I am using the MASM that comes with Visual Studio 2003 for some critical code in a VC project.
If a lable is used inside a procedure it is not recognized outside that procedure.

I used to do this with MASM 5.1 and TASM 3.2:

xxx proc
     bla bla
     jmp short zzz                    ;Used to work but not anymore - zzz is not recognized

yyy proc
     bla bla
zzz:
    more bla bla
    ret
yyy endp
xxx endp

Is there a directive or command line that would make it possible?
The -Zm doesn't help.

Of course this example can easily be re-written but I have a lot more complex code that works and I hate to modify it. :(

Thanks,
Gil
Title: Re: Can't jmp into proc
Post by: arafel on March 18, 2005, 05:10:49 PM
You need to specify the label as global.

some_label:   ; local, visible only inside a procedure
some_label::  ; global, visible everywhere
Title: Re: Can't jmp into proc
Post by: Gil on March 18, 2005, 08:02:41 PM
Quote from: arafel on March 18, 2005, 05:10:49 PM
You need to specify the label as global.

some_label:   ; local, visible only inside a procedure
some_label::  ; global, visible everywhere



Thank you very much, it's a life saver.
Gil
Title: Re: Can't jmp into proc
Post by: MichaelW on March 18, 2005, 08:06:28 PM
Thanks arafel, I had forgotten that.

From the MASM 6.0 Programmer's Guide:
Quote
By default, code labels defined with a colon are local. Place two colons after code labels if you want to reference the label outside of the procedure.
Quote
Compatibility between MASM 5.1 and 6.0
...
OPTION NOSCOPED
Under MASM 5.1 code labels are scoped (local to the current procedure) if the .MODEL directive specifies a language type. They are not scoped (not local to the current procedure) if a language type is not specified. Without OPTION M510 or OPTION NOSCOPED, code labels are always scoped.

If your MASM 5.1 code does not specify a language type and you want to assemble without OPTION M510, add OPTION NOSCOPED to you code.

To determine which labels need to be changed, remove the OPTION NOSCOPED directive and assemble the module. The assembler generates error A2006:

Undefined symbol : identifier

for each reference to a non-local label.