News:

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

Symbols

Started by EddieB, October 30, 2006, 10:43:23 AM

Previous topic - Next topic

EddieB

Hey

I'm still new to assembler, but ive come across code where they have @@ symbols for labels...

Could someone please explain, what they are, and why people use them?

Many thanks.

sinsi

From the MASM 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.
@B
The location of the previous @@: label.
@F
The location of the next @@: label.

Useful in loops where you can't be bothered making up unique labels
  mov ecx,3
@@:
  dec ecx
  jz @F      ;translated to "jz to the Forward @@:"
  call DoSomething
  jmp @B     ;translated to "jmp Back to the previous @@:"
@@:
  ret


Be aware, you can get some odd results using more than a couple of @@: labels in one PROC...
Light travels faster than sound, that's why some people seem bright until you hear them.

sluggy

That is an anonymous label, designed for short jumps.

Somewhere near the @@: will be a jump (either conditional or unconditional). Here is a quick pseudo code example:


shr eax, 1
jnc @F

invoke someFunction

@@:
do so more stuff.....


this tests the lowest bit of eax, if it is set it calls someFunction, if it is not set (determined by the carry flag being clear) then we jump over the function call. The @F tells us to jump foward to the first anonymous label we can find, equally i could have used @B to go backwards. IIRC, the maximum length for a jump to an anonymous label is 127 bytes, which is not much.




EddieB

Thank you for the descriptive posts guys :)

I understand now, the B and F confused me...

Cheers