flat assembler
Message board for the users of flat assembler.

Index > Main > Help: Label & constant

Author
Thread Post new topic Reply to topic
xRom



Joined: 26 Apr 2011
Posts: 13
xRom 26 Apr 2011, 19:20
Please,anybody, how to do this:
a = 1 ;generate label name
@1:

a = a + 1 ;generate next label name
@2:

a = a + 1 ;...next
@3:

etc...?
Post 26 Apr 2011, 19:20
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1044
Overflowz 26 Apr 2011, 19:23
you mean something like this ?
Code:
.data
a dd ?
.code
mov [a],1
@1:
inc [a]
@2:
inc [a]
@3:
....    
Post 26 Apr 2011, 19:23
View user's profile Send private message Reply with quote
xRom



Joined: 26 Apr 2011
Posts: 13
xRom 26 Apr 2011, 19:55
Overflowz wrote:
you mean something like this ?
....

No, I mean two macros "for" and "next" for example:
Code:
macro for p1,p2,p3 {
for_count = for_count + 1
for_nested = for_nested + 1
     if cond==false then jmp @for_exit
@for(for_count*1000+for_nested):
}

macro next  {
if cond==true then jmp @for
@for_exit(for_count*1000+for_nested):
for_nested = for_nested - 1 
}
   for i,1,2
       for j,1,100       ;nested for

       next
   next
    
Post 26 Apr 2011, 19:55
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1044
Overflowz 26 Apr 2011, 20:22
Ohh, sorry I don't know macro language here.. Smile
Post 26 Apr 2011, 20:22
View user's profile Send private message Reply with quote
xRom



Joined: 26 Apr 2011
Posts: 13
xRom 26 Apr 2011, 20:52
Overflowz wrote:
Ohh, sorry I don't know macro language here.. Smile

And you need this? When I'll deal can put it here Embarassed
Post 26 Apr 2011, 20:52
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1044
Overflowz 26 Apr 2011, 23:11
xRom
Hehe, I don't like macro things Razz I prefer hard way and I don't know why )) Thanks anyway Smile
Post 26 Apr 2011, 23:11
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 27 Apr 2011, 06:50
Creating loops this way is not a good idea for assembly language, because the code generated will be far from optimal and, worse, will prevent you from seeing better solutions.
If you really want to use loops this way - simply use Pascal or other HLL of choice. Smile
Post 27 Apr 2011, 06:50
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4623
Location: Argentina
LocoDelAssembly 27 Apr 2011, 20:17
I don't understand much what are you trying to do, but to answer your first message maybe this helps:
Code:
N equ 1

macro defLabel
{
  match n, N\{
    label\#n:
  \}

  rept 1 n:N+1\{N equ n\}
}


defLabel
defLabel

; Just to check the labels are defined:
jmp label1
jmp label2    
Post 27 Apr 2011, 20:17
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2893
Location: 0x77760000
typedef 27 Apr 2011, 21:43
He want's to generate the next label to be jumped at, given the current label he's at.

For example

label_1:

add size of opcodes that go in between and where they end is where the next label begins

label_1:
MOV EAX,2

So....
sizeof ( MOV EAX,2 ) + label_1 = label_2



I think that is what he want's to do. But I don't know why do that if you can just mark the labels..... Rolling Eyes
Post 27 Apr 2011, 21:43
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.