The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Astro on August 18, 2009, 01:56:43 AM

Title: Labels
Post by: Astro on August 18, 2009, 01:56:43 AM
A couple of questions:

1) Am I correct in thinking the size of a label in the source doesn't matter?

e.g.

I_AM_A_VERY_VERY_LONG_LABEL:

and

JH:

will compile to the same size code?

2) How does @@: and jmp @A work?

Best regards,
Astro.
Title: Re: Labels
Post by: dedndave on August 18, 2009, 02:18:42 AM
dunno 'bout "@A" - i think that is just a branch label
but
@@: is an anonymous branch label
it may be referenced by @B or (backward) @F (forward)
jz @F branches to the next (forward) anonymous label
jmp @B branches to the most recent (backward) anonymous label

the names can be any length up to 247 bytes
i sometimes make them long to write the code, then clean them up a little
Title: Re: Labels
Post by: Astro on August 18, 2009, 12:08:21 PM
Ahh! That makes sense. I wondered how they were referenced.

@A was just an arbitrary letter I chose - likely isn't valid then.

Thanks!  :thumbu

Best regards,
Astro.
Title: Re: Labels
Post by: hutch-- on August 18, 2009, 12:10:41 PM
Astro,

A label is just a notation for a location in code, in the final code there are no lables, just addresses that are targets for jumps and / or calls.
Title: Re: Labels
Post by: Astro on August 18, 2009, 10:26:58 PM
Hi,

Quotein the final code there are no lables, just addresses that are targets for jumps and / or calls.
That's what I thought it did, but it was based upon another architecture, and wasn't sure if the label made it into the final binary verbatim (it appeared that it wasn't the case, but wanted to check).

I was busy cleaning up some code I'd written and it prompted the question.

Best regards,
Astro.
Title: Re: Labels
Post by: FORTRANS on August 19, 2009, 01:32:45 PM
Hi,

   The easiest way to see this is with a program listing.


      13 0013  B9 0008                          MOV     CX,8
      14 0016                           @@:
      15 0016  90                               NOP
      16 0017  E2 FD                            LOOP    @@
      17
      18 0019  B9 0008                          MOV     CX,8
      19 001C                           Honking_Big_Label:
      20 001C  90                               NOP
      21 001D  E2 FD                            LOOP    Honking_Big_Label


   And noting that the generated code is the same.

Steve N.