flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Define label to somewhere else, inside of macro

Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 01 Apr 2009, 08:53
Wow that was fast. Thanks again. Very Happy


Last edited by Azu on 01 Apr 2009, 09:53; edited 1 time in total
Post 01 Apr 2009, 08:53
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20298
Location: In your JS exploiting you and your system
revolution 01 Apr 2009, 09:20
Well the question posed is not really clear to me but if I read it correctly you want to turn a string into a label?

Perhaps you should think about doing it the the other way around, turn a label in to a string:
Code:
something equ 0
macro someMacro foo {
  label foo at ebp + something
  fooString equ `foo
  db fooString,0
  something equ something + 4
}
someMacro abcdefg
someMacro abcdefgh
someMacro abcdefghi
mov eax,[abcdefg]
mov eax,[abcdefgh]
mov eax,[abcdefghi]    
Post 01 Apr 2009, 09:20
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 01 Apr 2009, 10:20
It this one of these preprocessor vs. macro again? Because I would, once again, use another approach here Smile

equ will finally end up with "something equ 0+4+4+4"
but using "="-sign, it will calculate and won't be unmanageably long.

EDIT: Just tested, the binaries will be the same.
Post 01 Apr 2009, 10:20
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 07 Apr 2009, 08:37
I'm really sorry to keep bugging you guys, but I've got another problem I can't figure out. Embarassed


Code:
label foo dword at ebp+something    
in my code works fine but when I try
Code:
label foo dword at ebp+something
label foo.bx dword at ebx+something    
It says error symbol already defined.
I'm certain that I didn't define it anywhere else.
Please help..


Also, what is wrong with this?
Code:
macro stdcall b,[arg]{
       if arg
              reverse bla <arg>
     end if
      common call b}
macro bla a{push a}    


It keeps saying "invalid value" with the IFs there? But if I remove the IFs it says "invalid operand" on functions with no args.. Sad
(also tried with "if [arg]", "if <arg>", and "macro bla a{if a push a endif}")

P.S. why can't I just do "reverse push <arg>"???
Post 07 Apr 2009, 08:37
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 07 Apr 2009, 09:17
Code:
nop
something db 5
label foo dword at ebp+something
label foo.bx dword at ebx+something
nop
mov [foo],6
nop
mov [foo.bx],7
nop

;Result=
;       90 05 90 67 66 C7 45 01
;       06 00 00 00 90 67 66 C7
;       43 01 07 00 00 00 90
    


Nope, its not defined in this code, so there should be an error in your code...
Post 07 Apr 2009, 09:17
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 07 Apr 2009, 09:27
But when I take the .bx one out of my macro it compiles fine.. x_x
Post 07 Apr 2009, 09:27
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20298
Location: In your JS exploiting you and your system
revolution 07 Apr 2009, 09:48
It is not defined in Madis731's code so it must be a bug in your code. If you need us to help you then you will have to post all the code. We can't fix what we can't see.
Post 07 Apr 2009, 09:48
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20298
Location: In your JS exploiting you and your system
revolution 07 Apr 2009, 09:55
Azu wrote:
Code:
macro stdcall b,[arg]{
   if arg
              reverse bla <arg>
     end if
      common call b}
macro bla a{push a}    
?
By default macros will start in forward mode. So you have this:
Code:
macro stdcall b,[arg]{
forward
  if arg
reverse
  bla <arg>
  end if
common
  call b}
macro bla a{push a}    
Which the assembler sees as this:
Code:
stdcall xyz,arg1,arg2,arg3
...
;the forward section
  if <arg1>
  if <arg2>
  if <arg3>
;the reverse section
  bla <arg3>
  end if
  bla <arg2>
  end if
  bla <arg1>
  end if
;the common section
  call xyz    
Is that what you intended to happen?
Post 07 Apr 2009, 09:55
View user's profile Send private message Visit poster's website 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.