News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Can't jmp into proc

Started by Gil, March 18, 2005, 05:00:41 PM

Previous topic - Next topic

Gil

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

arafel

You need to specify the label as global.

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

Gil

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

MichaelW

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.
eschew obfuscation