The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ShadowRayz on October 02, 2008, 11:24:55 AM

Title: Those @@: marks
Post by: ShadowRayz on October 02, 2008, 11:24:55 AM
I couldn't find an example of what those things are  :dazzled: , a small peace of code with explanation would be highly appreciated.
Title: Re: Those @@: marks
Post by: fearless on October 02, 2008, 11:45:06 AM
Microsoft Macro Assembler Reference: Symbols Reference

Quote@@:
Defines a code label recognizable only between label1 and label2, where label1 is either start of code or the previous @@: label, and label2 is either end of code or the next @@: label. See @B and @F.

Quote@F
The location of the next @@: label.

Quote@B
The location of the previous @@: label.

They can be used in code for branching: je @F, jnz @B, jl @F etc etc when testing for certain conditions then moves onto next @@: with the @F symbol or backward with the @B symbol to the last @@:

Here is an example (taken from the faster GetProcAddr function submitted by Lingo)

FindNextCharw:                          ;
       mov    ch,  [eax]                ; eax-> BaseDllName or FullDllName (Unicode)
       add    eax, 2                    ;
       cmp    ch,  5Ah                  ;
       ja     @f                        ;
       cmp    ch,  41h                  ;
       jl     @f                        ;
       or     ch,  20h                  ;
@@:                                     ;
       mov    cl,  [edx]                ; edx->lp dll name string "." or zero ended
       add    edx, 1                    ;
       cmp    cl,  5Ah                  ;
       ja     @f                        ;
       cmp    cl,  41h                  ;
       jl     @f                        ;
       or     cl,  20h                  ;
@@:                                     ;
       cmp    cl,  ch                   ;
       jne    Next_LDRw                 ;
       test   ch,  ch                   ;
       je     @f                        ;
       cmp    ch,  "."                  ;
       jne    FindNextCharw             ;
       cmp    dword ptr [esp+1*4], -1   ; flag for forwarded proc ->  If it is forwarded
       jne    FindNextCharw             ;           copy until "." , else until zero
@@:                                     ;
       mov    ebx, [esi+8]              ; ebx-> Base Dll Name address
       je     GetNextApi                ;

Title: Re: Those @@: marks
Post by: ShadowRayz on October 02, 2008, 11:59:51 AM
Thank you
Title: Re: Those @@: marks
Post by: P1 on October 02, 2008, 02:06:01 PM
One other consideration, but you would have figure it out with the Jump out of Range error.

These are assembled as short relative jumps.

Regards,  P1   :8)
Title: Re: Those @@: marks
Post by: Mark Jones on October 03, 2008, 04:10:03 PM
Are not they called "Anonymous Jump Labels?"