问题
I want to use local labels in my procedures to prevent the use of prefixes for common labels in my program. I tried using local labels (@@). According to my book, "The life of a local label extends only forward and back to the next nonlocal label". However, when I try to compile the file, the following error message is returned:
Turbo Assembler Version 3.1 Copyright (c) 1988, 1992 Borland International
Assembling file: test.ASM
**Error** test.ASM(20) Symbol already defined elsewhere: @@EXIT
**Error** test.ASM(33) Symbol already defined elsewhere: @@EXIT
Error messages: 2
Warning messages: None
Passes: 1
Remaining memory: 472k
Here is the source code:
Data segment
Data ends
Stack1 segment Stack "Stack"
dw 256 dup(?)
Stack1 ends
Code segment
assume cs:Code, ss:Stack1, ds:Data
.386
proc1 proc
; some code here
@@exit:
ret
proc1 endp
proc2 proc
; some code here
@@exit:
ret
proc2 endp
main proc
mov ax, Data
mov ds, ax
@@repeat:
call proc1
call proc2
jz @@repeat
@@exit:
mov ah, 4Ch
mov al, 0
int 21h
main endp
Code ends
end main
回答1:
Local symbols isn't enabled by default. To enable it, the LOCALS
directive is needed in the source. This directive must be placed in its own line and can be used multiple times. It needs one parameter that consist of two characters. This text will be used as the prefix for all local symbols.
For example: LOCALS @@
or LOCALS ZZ
来源:https://stackoverflow.com/questions/13221789/local-labels-in-tasm-symbol-already-defined