News:

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

Local (anonymous) labels with MASM/JWASM

Started by Gunther, September 15, 2010, 09:42:35 PM

Previous topic - Next topic

Gunther

Local labels are very useful. For example in blended code: the compiler will produce multiple instances of the inline assembly code if the function is inlined, which is quite likely to happen. If we use global labels, then there will be more than one label with the same name in the final assembly file, which of course will produce an error.

MASM/JWASM can use anonymous labels @@. So far, so good. But what can we do, if we need more then one local labels between two global labels? Assuming the following situation: We've to check 2 flags, lets say, carry and zero. This could look like the following pseudo code:


somewhere:

        ;check flags
        jc        @@10
        jnz       @@20

        ;some code here

        ;handle carry case here

@@10:

        ;some code
        jmp      anywhere

        ;handle zero case here

@@20:

        ;some code
        jmp      elsewhere

anywhere:


elsewhere:


I've written the pseudo code with TASM local labels; I could also use such labels with NASM (starting with a dot - .loop) or with GAS (starting with a number - 1). How should one solve that situation with MASM/JWASM anonymous labels?



Forgive your enemies, but never forget their names.

hutch--

Gunther,

Labels in MASM are local to the procedure they are used in unless you use the notation "label::" noting the "::" that gives the label global scope within the module it occurs in.

Anonymous labels in MASM "@@:" that are branched to using "@F" (the following "@@:" label OR "@B" to the preceding "@@:" label are LOCAL in scope to the procedure they occur in.

JWASM works the same way as MASM here.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Gunther

Thank you Hutch for the fast answer. That's it.

Gunther
Forgive your enemies, but never forget their names.


Gunther

Quote from: jj2007, September 16, 2010, at 07:15:38 AMsee also this recent thread.

Checked. Thank you.

Gunther
Forgive your enemies, but never forget their names.