News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

What is @F?

Started by Sergiu FUNIERU, February 19, 2010, 11:40:09 PM

Previous topic - Next topic

Sergiu FUNIERU

I'm trying to understand this code, from
C:\masm32\examples\exampl01\minimum\minimum.asm

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

What is @F? What is @@? What tutorial should I read first to understand these?

jj2007

@@: is an "anonymous" label. It saves you the work of inventing new unique labels.
jmp @F means jump forward to the next anonymous label
jmp @B means jump backward to the next anonymous label

For the guide, google for masm "programmer's guide", or try this post.

Sergiu FUNIERU

Thank you very much for your answer!

After you've told me what to search for, I found the manual, and the chapter (7) where it explains it.

Now I don't understand why would anyone want to use irrelevant names instead of suggestive ones. I mean, the machine code will be the same. Using anonymous labels is not a risk? For instance, I might jump to a wrong label, because I thought it was the next one, yet it was the second one. Does it worth the effort to make sure I jump to the right label?

I remember when I was taught the C language, that I should have used the smallest possible type for storing an 1 digit number. It was 1 one number! I understand that I save a huge amount of memory in case I applied this method to a 500x500 matrix. But for 1 number?

The program I quoted from has only 2 labels total. In my opinion, is harder for beginner to shift the focus from the main flow of the program to this kind of tricks.

jj2007

Quote from: Sergiu FUNIERU on February 20, 2010, 12:53:56 AM
Now I don't understand why would anyone want to use irrelevant names instead of suggestive ones. I mean, the machine code will be the same.

You are right for very small programs. But as soon as your code grows a bit, it can get very confusing. I use colours to help me understand my own jumps, see below, but there is no "unique" approach to this. As a rule, use @@ when the jumps are close, use proper names for far jumps, and do not use anonymous labels inside macros.

Quote            .if ShowProcName
               push esi   
               mov edx, proTaIndex
               or ecx, -1
         @@:   inc ecx
               mov esi, [edx+4*ecx]      ; esi is proc in the doc
               cmp eax, esi         ; eax is current find$
               jb @F
               test esi, esi            ; esi=0: no more proc in doc
               jne @B
         @@:   movi eax, 9               ; default for NoProc: tab
               dec ecx
               
jl NoProc            ; jump less ok, jnc not
               cmp ecx, LastEcx      ; same proc again?
               je NoProc
               mov LastEcx, ecx
               lea esi, [proTaText+8*ecx]
               lea esi, [esi+8*ecx]
         @@:   lodsb
               test al, al
               je @F
               stosb
               jmp @B
         @@:   movi eax, 9
      NoProc:      stosd   ; tab+delimiter
               dec edi
               pop esi
            .endif

FORTRANS

Quote from: Sergiu FUNIERU on February 20, 2010, 12:53:56 AM
Now I don't understand why would anyone want to use irrelevant names instead of suggestive ones. I mean, the machine code will be the same. Using anonymous labels is not a risk? For instance, I might jump to a wrong label, because I thought it was the next one, yet it was the second one. Does it worth the effort to make sure I jump to the right label?

   Quite right, if used badly, bad things will happen.  And if
you are unfamiliar with its usage, it can be confusing.
However it can be argued that for "obvious" jumps that
is is less confusing and cluttered to use an anonymous
jump.

Quote
The program I quoted from has only 2 labels total. In my opinion, is harder for beginner to shift the focus from the main flow of the program to this kind of tricks.


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


   Here you have data embedded in a stream of code.  It
is a straight forward jump, without any other meaning.  as
such, @@ is as meaningful as SkipOverMyData.

l
    jmp SkipOverMyData
      szDlgTitle    db "Minimum MASM",0
      szMsg         db "  --- Assembler Pure and Simple ---  ",0
SkipOverMyData:


   As in many things, it is a personal choice.  And you should
mix your feelings with "accepted practice" to produce the
best possible result.

HTH,

Steve N.

herge


Hi Sergiu:

Be careful with @@ labels.
Don't use if you can't see the code of the jump
and the label it goes to! ie Small jumps only.

It Only jumps to the nearest @@ label forward or backwards!
If you insert a new @@ label between two other @@ labels
I can personally say you will have a new logic error!

Regards herge

// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy