Reputation: 21
I'm kind of a rookie at programming in Assembly, and I need some clarification on the following kind of loops (@@, @B, @F).
When you have a routine like this:
Routine: PROC Value: Byte
MOV ECX, 3
MOVZX EDX, Value
MOV EAX, EDX
@@: SHL EAX, 8
OR EAX, EDX
LOOP @B
RET
Routine: ENDP
, what do the @@, @B mean?
As I was told those kinds of loops have some particularities. @B points to the first @@ in the routine and @F points to the last @@ in the routine, am I right? Is there anything else regarding these loops that I should know of? (I was also told that whenever they appear the loop goes 3 times, but I'm not sure about that).
Thanks in advance.
Upvotes: 1
Views: 971
Reputation: 95354
@@ is a local label. You can put it on any code line in your program. It is valid until you define the next @@ label. (Not the "first" or "last", just previous and next).
@b means "the previously (early source line) defined @@ label". @f means "the next defined @@ label".
The loop executes three times because the "LOOP" instruction decrements ECX (implicitly) on each iteration, and branches if the remaining value in ECX is not zero... and you loaded ECX with the value of 3 initially.
If you want to understand how the code works, you should assemble it using the MS Assembler, and then single step through it, looking at the registers as you go. Alternatively, read the Intel insturction set manually really carefully. (I did a lot of this when I first started programming the x86, and it was worth every minute, even for that huge document).
Upvotes: 1