flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > append Data at the End

Author
Thread Post new topic Reply to topic
chaoscode



Joined: 21 Nov 2006
Posts: 64
chaoscode
Hey, I want a Macro which i can give a Label value and a String.
the macro should append the String at the End of the File,
so that all strings are collected at the End.

sh when i type

[some code]
string lbl1,"Hallo Welt"
[some Code]
string lbl2,"Test123"
[some Code]
macro write_string_here

i get
[some code]
[some code]
[some code]
lbl1 db "Hallo Welt"
lbl2 db "test123"

I have a little bit of Code, but it doesent work.
with string i create a String
Code:
macro string strName,value

{

   str_Name equ strName

    str_Value equ value

     if ~ defined str_Count

     str_Count = 0

        end if

  str_Count = str_Count + 1

}

    


and with restore_String i want to write the Strings all there.
Code:
macro restore_String

{



      rept str_Count

      if ~ used str_Name

        restore_String_pos = $

          str_Name db str_Value,0

         str_Name#.Size equ $-restore_String_pos

         restore str_Name

        str_Count = str_Count - 1

     end if

      end rept

}
    


the Problem is, that the equ-object "str_name" and "str_value"
is replaced by the First variable and because of that can't be
restored again.

has somebody any idea?

mfg Dennis[/code]

_________________
Jedes mal, wenn einer was anderes als Englisch redet versteh ich mal wieder kein Wort.
Every time someone talks something other than englisch, i can't understand anything.
Post 27 Nov 2009, 01:54
View user's profile Send private message ICQ Number Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
Hallo chaoscode,
if i understand what you require
try here,
http://board.flatassembler.net/topic.php?p=74292#74292

ich habe noch eine bessere macro gemacht, die ich aber im moment nicht finden kann,Mad
es tut mir leid
probier mal die da,
and let me know
tschuss

hopcode
Post 27 Nov 2009, 04:05
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
[edit: see hopcode's code]

Hope that helps Cool


Last edited by cod3b453 on 06 Dec 2009, 19:16; edited 1 time in total
Post 27 Nov 2009, 16:32
View user's profile Send private message Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael
hopcode wrote:
ich habe noch eine bessere macro gemacht
Kannst du uns sagen, warum deine Macro ist besser? Was macht deine Macro, was andere machen nicht? Or something, my German is probably even worse than English Wink
Post 27 Nov 2009, 18:51
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
Fanael wrote:
Was macht deine Macro, was andere machen nicht?

Eigentlich nichts, keine Programmierungsfähigkeit,keine Zauberei.
Sie kocht aber Kaffe! Wink

hopcode

btw. Du kannst ausgesprochenen gut Deutsch! lebst du/hast du in Deutschland
gelebt ?
Post 27 Nov 2009, 20:56
View user's profile Send private message Visit poster's website Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael
hopcode wrote:
Du kannst ausgesprochenen gut Deutsch! lebst du/hast du in Deutschland
gelebt ?
Ich bin in Deutschland geboren, aber ich bin nach Polen umgezogen, wenn ich zwei Jahre alt war. Ich kann nur das, was ich in der Schule gelernt hat.
Post 27 Nov 2009, 23:00
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
Ich habe endlich die Macro wieder gefunden... Cool
Code:
macro @init {
  asize = 0
  alist equ
}

macro @str name,[args]{
common
 virtual at benny+asize
    name db args
    asize = asize + $-name
    name#.#len = $-name
 end virtual
  match items,alist \{alist equ alist,args\}
  match ,alist \{alist equ args\}
}

macro @build {
 if asize
   benny:
   match i,alist\{db i\}
 end if
}
    

usage
Code:
;---- code------
section ".code" code readable executable
 @init
 start:

 mov eax,alfa
 @str alfa,"ABC","EFG",0
 @str beta,"12345","6789",0

 mov ecx,alfa.len
 mov eax,beta
 mov ecx,beta.len
  ret
;----------- data follows at the end -----------
 section ".data" data readable writeable
   @build
    


Enjoy,
hopcode
Very Happy
Post 04 Dec 2009, 15:40
View user's profile Send private message Visit poster's website Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
Hallo Fanael,

1) Analyzing the cod3b453 macro i have seen that it has problems
with the .dotting capabilities of fasm. You cannot compile
my suggested code (as shown in usage) using that macro and dotted labels

2) Now Consider that symbols catenation, for example,

__string_table_\#i\#_name equ id

it is not using (imho) the best feature of fasm, considering other features
like load/store and virtual.

As you know, .dotting capability gives localization to labels.
(but not only).

3) Also, that macro applies almost 90% in a pre-procedural stage.
But as the macro begins to realize labels, it is to say

__string_table_\#j\#_name:

it is too late for the assembler to assemble code that have been
never addressed, (even if) being invoked. I would not use or recommend
taking advantage from that macro (i am not personally interested in the
matter when stating this,because i myself dont use anymore mine too),
unless cod3b453 improves it with a localizing-.dotting capabilitiy.

to cod3b453, how could the problem be solved in your pre-procedural way ?

to Fanael, Do you confirm the BIG difference ? Wink

p.s.
Note that I have written this post only for the sake of improving
my own capabilities to express and figure out in few words a problem.

Regards,
hopcode
Post 04 Dec 2009, 23:23
View user's profile Send private message Visit poster's website Reply with quote
chaoscode



Joined: 21 Nov 2006
Posts: 64
chaoscode
Hey, thank you all^^
i tried it and it works fine^^


euer deutsch ist gut.
Ich kann euch sehr gut verstehen.

_________________
Jedes mal, wenn einer was anderes als Englisch redet versteh ich mal wieder kein Wort.
Every time someone talks something other than englisch, i can't understand anything.
Post 05 Dec 2009, 01:54
View user's profile Send private message ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
Yes, my macros were lame Sad They're just what I was using for one of my projects.
Post 06 Dec 2009, 19:08
View user's profile Send private message Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael
Yes, I confirm the difference.
Post 06 Dec 2009, 19: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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.