In MASM 5.1x if you aren't using a .MODEL
directive with a language type then code labels inside a PROC
are globally scoped. This is why your code assembles in MASM 5.1x. In JWASM and MASM 6.1+ it is a bit different because code labels that are followed by a :
are always locally scoped in a PROC
. This results in the errors you are seeing. The MASM 6.1 documentation covers this issue:
MASM 5.1 considers code labels defined with a single colon inside a procedure to be local to that procedure if the module contains a .MODEL directive with a language type
The solution is to use ::
following a label rather than :
to mark a code label as globally defined. The documentation goes on to say:
You can use the double colon operator to define a non-scoped label
Using ::
should make your code assemble with MASM 5.1+, 6.1+, and JWASM. This code:
func1 proc
label1:
jmp label2
func1 endp
func2 proc
label2:
call label1
func2 endp
Should work if written as:
func1 proc
label1::
jmp label2
func1 endp
func2 proc
label2::
call label1
func2 endp
You can use the -Zm
option (not to be confused with -mz
) enables MASM 5.1 compatibility. Running JWASM this way should allow your code to assemble without any changes:
jwasm -Zm filename.asm
Using this method will make locally scoped labels in a PROC
globally scoped. The other changes that occur are:
Option -Zm (or setting OPTION M510) will do:
- set OPTION OLDSTRUCTS
- set OPTION DOTNAME
- set OPTION SETIF2:TRUE
- set OPTION OFFSET:SEGMENT (if no model is set)
- set OPTION NOSCOPED (if no model with language specifier is set)
- allow to define data items behind code labels
- allow "invalid" use of REP/REPE/REPNE instruction prefixes
- change precedence of [] and () operator from 1 to 9. Hence expression
-5[bx] is parsed as (-5)[bx], while without -Zm it is
parsed as -(5[bx]), which generates an error.
For JWASM and MASM 6.1+ you can also specify the no scope option at the top of an assembly module with this directive:
OPTION NOSCOPED
This option doesn't exist in MASM 5.1x as this is the behaviour for that assembler. You would have to remove this directive from your assembly code if assembling with MASM 5.1x. The MASM 6.1 documentation describes this option as:
The information in this section applies only if the .MODEL directive in your MASM 5.1 code does not
specify a language type. Without a language type, MASM 5.1 assumes code labels in procedures
have no “scope” — that is, the labels are not local to the procedure. When not in compatibility mode,
MASM 6.1 always gives scope to code labels, even without a language type.
To force MASM 5.1 behavior, specify either OPTION M510 or OPTION NOSCOPED in your code