flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > new _align

Author
Thread Post new topic Reply to topic
DMD



Joined: 05 Jun 2006
Posts: 24
DMD 21 Aug 2009, 05:53
hello everybody!

my friend wrote for me this macro:

Code:
macro _align _offset, _byte
 {
 if (_offset - 1) and $
 times _offset - ((_offset - 1) and $) db _byte
 end if
 }    


but I've got error

Code:
 invalid expression
 command:
 if(16-1)and $    


can somebody help? Embarassed

thank in advance! Smile

ps/
the autor's just busy now and can't help... Crying or Very sad
Post 21 Aug 2009, 05:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20356
Location: In your JS exploiting you and your system
revolution 21 Aug 2009, 06:02
I think you are using one of the relocatable format outputs (I can't be sure because you didn't post all your code). But try this:
Code:
macro _align _offset, _byte
 {
 if (_offset - 1) and RVA $
 times _offset - ((_offset - 1) and RVA $) db _byte
 end if
 }    
Post 21 Aug 2009, 06:02
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 21 Aug 2009, 06:13
What kind of alignment the macro does? (Or how is it used?)
Post 21 Aug 2009, 06:13
View user's profile Send private message Reply with quote
DMD



Joined: 05 Jun 2006
Posts: 24
DMD 21 Aug 2009, 09:38
I'm really sorry I didn't post the code ! Embarassed

to revolution

your macro is work perfect! thanks alot! Smile

ps/

to LocoDelAssembly

ok,
Code:
_align  10h, 20h    

Wink
Post 21 Aug 2009, 09:38
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 21 Aug 2009, 16:06
hehe, sorry, I though it couldn't work Razz
Post 21 Aug 2009, 16:06
View user's profile Send private message Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael 24 Aug 2009, 16:21
The name of the macro seems ugly for me (it begins with underscore...), can't it be called "align" (same as assembler's directive)? Consider this one:
Code:
macro align off*, b {
  if ~ b eq
    if (off - 1) and RVA $
      times off - ((off - 1) and RVA $) db b
    end if
  else
    align off
  end if
}    
Now you can write as follows:
Code:
align 16 ;padded with nops
db 0
align 16, 0 ;padded with zeros
db 1    
Post 24 Aug 2009, 16:21
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.