The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Tosse on February 12, 2008, 09:53:38 AM

Title: @@ label
Post by: Tosse on February 12, 2008, 09:53:38 AM
In hutch´s bubblesort example the code is containing @@ labels, what is it good for and how does it works?

Example:

Quotemain proc

    push ebx
    push esi

    print "Unsorted",13,10

    mov esi, OFFSET narr
    mov ebx, LENGTHOF narr

  @@:
    print str$([esi]),13,10
    add esi, 4
    sub ebx, 1
    jnz @B

    invoke bubble_sort,OFFSET narr,LENGTHOF narr

    print chr$(13,10)
    print "Sorted",13,10

    mov esi, OFFSET narr
    mov ebx, LENGTHOF narr

  @@:
    print str$([esi]),13,10
    add esi, 4
    sub ebx, 1
    jnz @B


    pop esi
    pop ebx

    ret

main endp
Title: Re: @@ label
Post by: Rainstorm on February 12, 2008, 10:36:01 AM
Its just a label masm allows you to use.. if you're hard up for a name
jmp @F will go to the next '@@:' label & jmp @B will jump to the last (previous) @@: label
For example in the above code jnz @B loops,(..back to the previous @@:   Label) as long as ebx is not 0
Title: Re: @@ label
Post by: Tosse on February 12, 2008, 11:21:04 AM
Thanks for the reply Rainstorm. I understand how it works now. Playing with @@ and loops and looking in olly debugger.  :8)
Title: Re: @@ label
Post by: white scorpion on February 12, 2008, 08:24:44 PM
I'm glad they exist, I use them quite often, but do keep in mind that it can get quite messy if you have nested loops using these labels ;)
Title: Re: @@ label
Post by: Tosse on February 13, 2008, 05:13:59 PM
I can imagine that  :bg but i try to avoid nested loops - is that stupid? -  i mean performance wise. Any example where a nested loop is required? or is all code rewritable to not use a nested loop.
Title: Re: @@ label
Post by: Rockoon on February 14, 2008, 06:36:37 AM
One type of algorithm that I believe requires nested loops (cant think of a way not to nest them) is signal convolution...

http://www.wam.umd.edu/~toh/spectrum/Convolution.html

"Convolution is an operation performed on two signals which involves multiplying one signal by a delayed version of another signal, integrating or averaging the product, and repeating the process for different delays."