The following code is from the masm package. This is "minimum.asm" :

.386
.model flat, stdcall
option casemap :none ; case sensitive

; #########################################################################

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

; #########################################################################

.code

start:

jmp @F
szDlgTitle db "Minimum MASM",0
szMsg db " --- Assembler Pure and Simple --- ",0
@@:

push MB_OK
push offset szDlgTitle
push offset szMsg
push 0
call MessageBox

push 0
call ExitProcess

; --------------------------------------------------------
; The following are the same function calls using MASM
; "invoke" syntax. It is clearer code, it is type checked
; against a function prototype and it is less error prone.
; --------------------------------------------------------

; invoke MessageBox,0,ADDR szMsg,ADDR szDlgTitle,MB_OK
; invoke ExitProcess,0

end start


I don 't understand the "@@:/jmp @F" syntax. They seems to be related => the "jmp @F" seems to jump torward "@@:" but why they doesn't have the same name ?

In other snippets code, I found the same syntax but with many "@@:" and "jmp @B" !!!

Two @@: in the same code. How this is possible to write two labels with the same name ? And why sometimes the letter "F" and why sometimes the letter "B" ?

Can someone explain me please ? :confused:
Posted on 2002-02-06 10:39:42 by Djizeus
E.G.


@@: ;-----> First

cmp eax, 1 ;compare the value of eax and 1
je @f ;if it's equal then jump "forward"(Second @@)
jmp @b ;else jump "backward"(First @@)

@@: ;-----> Second

When you assemble your code those two @@ are actually different labels, MASM did that for you so that you don't need to fiddle around with a lot of labels.
Posted on 2002-02-06 10:48:22 by stryker
Wow what a fast answer !

I understand all now :grin:

Thx :alright:
Posted on 2002-02-06 10:57:27 by Djizeus
They are a true asset to the Compiler, but like all things need a bit of respect.

The main issue that comes to mind is if you use these in MACRO's as well as code, you can end up with some really hard to debug problems.

ie)


myMacro MACRO val:req
...
je @F
...
@@:
more code...
ENDM


In your Program...

jne @F
xor eax, eax
myMacro eax
sub eax, 2
@@:
invoke this..


In this case, if you see the problem, the macro will get inserted between the "jne @F" and the "@@". SInce the macro itself has a @@: within it, the actual jne@F statment will jump into the middle of the "stamped-into-place" macro code. Even tho, from a higher level point of view the origional intention was to jump to the @@: following the "sub eax,2".

If this were to run, a entire slew of possible bugs could arrise from crashing to just "unpredicable" behavior. All because its not intuitively obvious that the first jne is jumping into code places by the macro!!

But dont let this scare you from using them, i do all the time, just be aware of potential pit-falls.... In general, i dont use any @@:'s in a macro to avoid this problem.

:alright:
NaN
Posted on 2002-02-06 10:59:36 by NaN
NaN, a design error, IMO.
Posted on 2002-02-06 11:27:57 by bitRAKE
I would like to know if it is possible to have something like @B but to jump to the label higher than @@:

Exemple :

@@:
; do some operation
dec ecx
jnz @B
@@:
; do another operation
cmp eax, 0
jne @BB (to jump to the first @@: and not the previous one).

Is it possible to have the same label names in the same source but not in the same procedure (I would like to test, but I don't have MASM here ;_; ) ?

Thanks.
Posted on 2002-02-06 12:23:37 by JCP
Readiosys, that doesn't work, but SpASM can do it!
Posted on 2002-02-06 12:43:27 by bitRAKE
@B and @F ... yuck. Descriptive names are nicer. Just my little personal
opinion.

Readiosys, I believe masm defaults to local scope for labels declared
within proc blocks... so you should be able to use "myFunkyLabel:"
in multiple procs.
Posted on 2002-02-06 12:51:15 by f0dder
MASM's anonymous labels are one of the blessings in an assembler and you really miss them when you are coding assembler in a compiler or another assembler as it prevents the endless invention of label names when they are not needed.


jmp @F ; jump forward to next @@:

; your code

@@: ; the target of BOTH @F and @B

; more of your code

jmp @B ; jump back to last @@:

NaN has made a good point about not using them in MACROs as it can leave you with unintuitive bugs that are hard to find, in a macro, use the LOCAL directive and NAME your lable and MASM will ensure that the label is unique when the macro is expanded to make sure you do not get any duplicate labels.

Regards,

hutch@movsd.com
Posted on 2002-02-06 17:04:50 by hutch--