I'm getting an error message when assembling code in which an instruction references a label in a different procedure.
This code generates two errors, assembler is JWasmR v2.12pre:
single segment stack
assume cs:single,ds:single,ss:single
start:
mov ax, cs
mov ds, ax
mov ax, 4c00h
int 21h
func1 proc
label1:
jmp label2
func1 endp
func2 proc
label2:
call label1
func2 endp
align 2
s16 db 256 dup (0ffh)
single ends
end start
Error messages:
test1.asm(13) : Error A2102: Symbol not defined : label2
test1.asm(20) : Error A2102: Symbol not defined : label1
I think each label symbol is local to it's respective procedure. I would like to disable this functionality globally, or bypass it on an individual basis. I've tried using the -Zf
option which makes all symbols public. Documentation can be found here.
In MASM 5.1x if you aren't using a
.MODEL
directive with a language type then code labels inside aPROC
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 aPROC
. This results in the errors you are seeing. The MASM 6.1 documentation covers this issue:The solution is to use
::
following a label rather than:
to mark a code label as globally defined. The documentation goes on to say:Using
::
should make your code assemble with MASM 5.1+, 6.1+, and JWASM. This code:Should work if written as:
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:Using this method will make locally scoped labels in a
PROC
globally scoped. The other changes that occur are:For JWASM and MASM 6.1+ you can also specify the no scope option at the top of an assembly module with this directive:
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: