News:

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

@@ label

Started by Tosse, February 12, 2008, 09:53:38 AM

Previous topic - Next topic

Tosse

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

Rainstorm

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

Tosse

Thanks for the reply Rainstorm. I understand how it works now. Playing with @@ and loops and looking in olly debugger.  :8)

white scorpion

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 ;)

Tosse

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.

Rockoon

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."

When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.