flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > String pointer table

Author
Thread Post new topic Reply to topic
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
I'm trying to make a string pointer table. I know there is an example here somewhere, but I can't find it.

I'm stuck at generating unique labels for the strings, how can you append the number instead of 'n'? I probably already know how, but my brain isn't working right now.

Code:
macro stringtable [strings*]
{
   common
      label .
   forward
      n=0
      dd .#n
      n=n+1
   forward
      .#n: db strings
}    

_________________
This is a block of text that can be added to posts you make.
Post 17 Dec 2010, 15:43
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17658
Location: In your JS exploiting you and your system
revolution
If you use "label ." then you have to use struc (not macro).

Use local to generate unique names
Code:
struc stringtable [strings*]
{
    common
    label .
    forward
      local ..n
   dd ..n
    forward
       ..n: db strings
}    
Post 17 Dec 2010, 15:49
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3032
Location: vpcmipstrm
bitRAKE
Is this sufficient?
Code:
macro A [B*] {
; forward ; this is implied - not needed
    local ..t
    dd ..t
  forward
    ..t db B
}

.: A 'zero','one',<'two',13,10,0>,'three'    
Post 17 Dec 2010, 15:52
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
revolution: Actually it was struc originally, I changed it while testing. This should work! Just need to add some .sizes.

bitRAKE: The only difference is that I would need to use label with a : to address the list?

edit: how can I define .size constants when the labels are local?
Post 17 Dec 2010, 15:57
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3032
Location: vpcmipstrm
bitRAKE
There isn't any size checking for ":" labels - be careful, FASM will not error on mov al,[.] - iirc, no different than using "label .".
Code:
struc A [B*] { 
  common
    .: 
  forward
    local ..t 
    dd ..t 
  common
    .entries = ($-.) shr 2
  forward 
    ..t db B 
}    
Post 17 Dec 2010, 16:12
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
I did it like this, interleaved pointers with string lengths:

Code:
struc stringtable [strings*]
{
    common
        label .
    forward
        local ..n
        dd ..n
        dd ..n#.size
    forward
        ..n: db strings
        ..n#.size=$-..n
}    

_________________
This is a block of text that can be added to posts you make.
Post 18 Dec 2010, 18:41
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.