flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Label problem.

Author
Thread Post new topic Reply to topic
j-coder



Joined: 03 Jul 2008
Posts: 2
j-coder 04 Jul 2008, 00:14
Hey,

I'm new in a forum, but i have programmed about 5 years with C++ and 2 years with a NASM. My frend told me about a FASM and i tried and loved it! Now i have one question.

Can someone tell to me is it possible to reuse same lable?

I mean something like this:
Code:
      mov ECX, 10

   _loop:
      dec ECX
      cmp ECX, 0
      ja loop

      release _loop

      mov ECX, 10

   _loop:
      dec ECX
      cmp ECX, 0
      ja _loop

    

I hope you answer quickly.

PS. Sorry my bad english.
Post 04 Jul 2008, 00:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 04 Jul 2008, 01:23
You have a few problems above:
  • repeated label "_loop". Try either use unique label or use the anonymous "@@" and "@B" set.
  • What is "release"? It is not an opcode or an assembler directive. Is it a macro you have defined?
Maybe you can try this:
Code:
      mov ECX, 10

   _loop1:
      dec ECX
      cmp ECX, 0
      ja _loop1

      mov ECX, 10

   _loop2:
      dec ECX
      cmp ECX, 0
      ja _loop2     
or this:
Code:
      mov ECX, 10

   @@:
      dec ECX
      cmp ECX, 0
      ja @b

      mov ECX, 10

   @@:
      dec ECX
      cmp ECX, 0
      ja @b     
BTW: you don't need the cmp instructions if there is no code between dec and jcc. So you can also do this:
Code:
      mov ECX, 10

   @@:
      dec ECX
      jnz @b

      mov ECX, 10

   @@:
      dec ECX
      jnz @b     
Lastly, you can use the loop to make the whole thing very neat and tidy
Code:
      mov ECX, 10
   @@:
      ;other code goes here
      loop @b

      mov ECX, 10
   @@:
      ;other code goes here
      loop @b     
Post 04 Jul 2008, 01:23
View user's profile Send private message Visit poster's website Reply with quote
j-coder



Joined: 03 Jul 2008
Posts: 2
j-coder 04 Jul 2008, 08:25
Thanks revolution. I think that @@ was that what i meant.
Post 04 Jul 2008, 08:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.