The MASM Forum

General => The Campus => Topic started by: Lonewolff on April 12, 2018, 08:16:25 AM

Title: What is @@:?
Post by: Lonewolff on April 12, 2018, 08:16:25 AM
What is @@:?

I have seen this label in a few code examples, but no idea what its purpose is.

If anyone can enlighten me, that would be awesome.  8)
Title: Re: What is @@:?
Post by: zedd151 on April 12, 2018, 08:30:22 AM
unnamed next label or unnamed previous label.

jump @f means jump forward to next @@:
jump @b means jump back to last @@:
can be used with any jumps conditional or unconditional.

convenient for a quick piece of code.

call @f wouldnt work afaik.

edit= brain cramp :lol:
and addition
Title: Re: What is @@:?
Post by: Lonewolff on April 12, 2018, 08:36:02 AM
Ah ok. Makes sense (sort of  :bgrin:)

I'll have a play and see how it works.

Thanks again. You guys are cram packed full of information.  8)
Title: Re: What is @@:?
Post by: zedd151 on April 12, 2018, 08:40:23 AM
Quote
Thanks again. You guys are cram packed full of information.  8)

I've got my moments.
Title: Re: What is @@:?
Post by: jj2007 on April 12, 2018, 09:02:38 AM
Quote from: zedd151 on April 12, 2018, 08:30:22 AMcall @f wouldnt work afaik

"afaik" = "I was too lazy to try"
include \masm32\include\masm32rt.inc ; plain Masm32 for the fans of pure assembler

.code
@@: MsgBox 0, "It works!", 0, MB_OK
ret

start: call @B
exit

end start
Title: Re: What is @@:?
Post by: zedd151 on April 12, 2018, 09:07:53 AM
Quote
"afaik" = "I was too lazy to try"

sticks and stones, jochen.

as a matter of fact I never even considered it until this topic came up today.

Now I learned something new today. Thank you!   :icon14:

edit for missing bracket.
Title: Re: What is @@:?
Post by: LordAdef on April 12, 2018, 09:35:05 AM
Quote from: Lonewolff on April 12, 2018, 08:16:25 AM
What is @@:?

I have seen this label in a few code examples, but no idea what its purpose is.

If anyone can enlighten me, that would be awesome.  8)


They are rather useful when avoing duplicate label, such for instance when expanding macros.


Say it you have some Macro:


foo MACRO
     code bla bla
     bla
      bla bla bla
      done:
end m




If you use foo macro twice, you will have a duplicate "done:" label


.code
foo
foo


; you ended up with an error... two labels called "done:"











Title: Re: What is @@:?
Post by: zedd151 on April 12, 2018, 05:19:54 PM
Quote from: LordAdef on April 12, 2018, 09:35:05 AM
They are rather useful when avoing duplicate label, such for instance when expanding macros.

Thank you, Lord! (Adef that is) --- always wanted to say that --- lol

Thats the part I was missing. Probably the main reason for its existence. (@@:)


Title: Re: What is @@:?
Post by: hutch-- on April 12, 2018, 05:31:49 PM
The "@@:" notation are actually called anonymous labels and they serve a purpose where repeatedly creating named labels is a pain. The usage has been explained above.

jmp @B   ; means jump to the previous @@: label
jmp @F    : means jump to the next @@: label.
Title: Re: What is @@:?
Post by: jj2007 on April 12, 2018, 05:56:43 PM
Quote from: zedd151 on April 12, 2018, 09:07:53 AM
Now I learned something new today. Thank you!   :icon14:
Me too, thanks (https://www.urbandictionary.com/define.php?term=sticks%20and%20stones) ;)

Quote from: LordAdef on April 12, 2018, 09:35:05 AMThey are rather useful when avoing duplicate label, such for instance when expanding macros.

Alex, that is very risky. Imagine this scenario:
cmp eax, ecx
je @F
DoSomeStuff
@@:


Now the Million Dollar Question: What happens if there is an anonymous label inside your DoSomeStuff macro?
Title: Re: What is @@:?
Post by: LordAdef on April 12, 2018, 06:39:16 PM
QuoteNow the Million Dollar Question: What happens if there is an anonymous label inside your DoSomeStuff macro?


Surely a big and ugly mess  :dazzled:


I only used the macro as a quick example of label duplication. I wouldn't nest anonimous labels anyway, but thanks for pointing that out, it's indeed a risk