flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Whitespace and its use in macroinstructions

Author
Thread Post new topic Reply to topic
hafai



Joined: 12 Jun 2011
Posts: 8
hafai 08 Dec 2011, 00:13
I'm looking to use whitespace in my macroinstructions, more specifically a tab character in its name. But as macronames aren't quote-enclosed something like the following won't work.
Code:
macro "\t rest_of_macro_name" arg    
I'm not even sure if fasm understands escape-sequences like that as I have always had to manually enter the hex-value of what normally would be escaped when writing string literals. So basically I'm looking for confirmation as to whether or not I need to find a new way to achieve what I want.[/code]
Post 08 Dec 2011, 00:13
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1657
Location: Toronto, Canada
AsmGuru62 08 Dec 2011, 01:05
Curious.... why that feature may be needed?
What does a TAB in the macro name can be used for?
Post 08 Dec 2011, 01:05
View user's profile Send private message Send e-mail Reply with quote
hafai



Joined: 12 Jun 2011
Posts: 8
hafai 08 Dec 2011, 04:45
I actually want to create a macro that has the name of something like a tab or a certain number of spaces. It would then have the next word tell it which sub part (with an if statement) of the macro to execute. So something like, "[TAB]/[certain number of spaces] sub-part args" would call the [TAB] macro with the name and args. As I already format my code using tabs I could then naturally invoke my macros without having to remember the [TAB]. And as long as I don't create a sub-part that has the name of a standard assembly instruction then the if statements would cause normal instructions to operate normally.

I'm not sure if I'm describing what I want to do quite right but I just need to know if FASM can do this by default. If not then I guess I'll have to re-compile it with some modifications to handle what I want.
Post 08 Dec 2011, 04:45
View user's profile Send private message Reply with quote
addes3



Joined: 09 May 2011
Posts: 29
addes3 08 Dec 2011, 20:56
Sorry, but this is not supported by FASM, as it removes all extra whitespace. FASM doesn't support escape-sequences.

This is an extremely odd request. Just so you know, a macro can use old macros with the same name or the actual instruction.

Example:
Code:
macro mov op1,op2,op3
{
   if op3 eq
      mov op1,2op2
   else
      mov op1,op2
      mov op2,op3
   end if
}    
Post 08 Dec 2011, 20:56
View user's profile Send private message Reply with quote
hafai



Joined: 12 Jun 2011
Posts: 8
hafai 09 Dec 2011, 12:50
I was aware of 'overloading' an instruction with macro-instructions as the preprocessor just outputs assembly (well, text that the rest of the assembler hopes is legal source code for the following stages). I may have found a better solution for my problem. One that may actually be far better.

But I have one more question. Does the preprocessor get run on the source code several times? Until it returns with no changes? So if in the process of resolving a macro-instruction it creates a new one it would then resolve the new one during a second run through?
Post 09 Dec 2011, 12:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20416
Location: In your JS exploiting you and your system
revolution 09 Dec 2011, 20:34
hafai wrote:
But I have one more question. Does the preprocessor get run on the source code several times?
The preprocessor is single-pass. The assembler is multi-pass.
Post 09 Dec 2011, 20:34
View user's profile Send private message Visit poster's website Reply with quote
hafai



Joined: 12 Jun 2011
Posts: 8
hafai 09 Dec 2011, 21:30
Okay. Thank you.
Post 09 Dec 2011, 21:30
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.