I know in masm you could use jmp @F to go to the next location of the @@: and @B to go backwards... makes for nice non named labels is it possible to do this with nasm? I've looked and can't find anything more than just prefixing labels with "." to make them local. but I will have a long list of labels I will need to make and i don't care to name. is there some way to do this?
Posted on 2008-02-01 00:49:43 by jakor
The general consensus is that @@ labels are uglyish.

Use named (local) labels or move to a HLL :)
Posted on 2008-02-01 04:55:08 by f0dder
so in a giant list of configuration gaining from scripts we need to label them all. I think it has good uses I'll give an example:

  call GetPrivateProfileString,szIniSection_Main,szIniMain_MessageBox_str,szIniMain_MessageBox,szIniBuffer,IniBufferSize,szIniFile
  cmp byte , "0"
  jne @F
  mov byte , "0"
  call GetPrivateProfileString,szIniSection_Main,szIniMain_DoSomething_str,szIniMain_DoSomething,szIniBuffer,IniBufferSize,szIniFile
  cmp byte , "0"
  jne @F
  mov byte , "0"

with the @@ you can add in an indefinate ammount of labels without needing to find a unique name for each. This helps when someone else would like to add in one. they can just add theirs in instead of trying to add names to each of the lables they use. It may be ugly, but @@ wasn't for nameing a section, it was for doing long lists of jumps for configuration or whatever. I think it looks easier to read this way. but I have programmed masm for years.
Posted on 2008-02-01 11:20:51 by jakor
Anonymous labels (@@) are good thing for often repeated very short jump, and even less uglyish than named label in this case
Posted on 2008-02-01 12:15:24 by vid
Anonymous labels can be done using macros in NASM. It was one of the first things added to my BKMACROS.INC set. One of these days I might clean up some of the testbed code out of it and do a release version of BKMACROS.INC

%idefine @b %$B
%idefine @f %$F

%macro @@ 0
%ifctx _anon_labels_
%push _anon_labels_

It requires you to be within the _anon_labels_ context to begin with so you should use @@ sometime before you decide to use @F or @B. For example:

    ; do something
    je @F
    ; do something else

If you were to remove the first @@ then the 'je @F' line would fail because it wouldn't be able to find the %$F macro label. It's pretty simple, just remember to always use that previous @@ and it works like a charm (and mind any new context changes).

Bryant Keller
Posted on 2008-02-01 17:31:43 by Synfire
and adding the @@ just after __start will not be a problem... masm just automatically does this i assume because @B without @@ means begining of code and @F without @@ means end of code. Thank you Synfire!
Posted on 2008-02-02 00:52:43 by jakor
Nah, MASM does this internally so it can work based on the occurance of @F and @B whereas we need to setup for @F and @B with the NASM macro version.
Posted on 2008-02-02 18:38:11 by Synfire
I'll drop the comment about using assembly for what it's good at and HLLs for what they're good at. (Okay, so I didn't).

Instead I'll say this: refactor your code :). For configuration reading, set up a table of regkeys/whatever, pointer to variable you want the info in, and possibly a variable type. Write a loop for processing that data. Presto, you get rid of a lot of ugly & repetitive code, and the need for anonymous labels.
Posted on 2008-02-03 17:18:58 by f0dder