flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > compare before macro?

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 05 Aug 2016, 16:32
Code:
if version < 201109 {
  macro xchg op1, op2 \{
    push op1 op2
    pop  op1 op2
  \}
}    
Post 05 Aug 2016, 16:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 05 Aug 2016, 16:38
Are you trying to conditionally define a macro? For that you can only use other preprocessor commands (rept, match, etc.). "if" is processed during assembly time so it won't work there.
Post 05 Aug 2016, 16:38
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 05 Aug 2016, 16:59
I put the topic in Compiler Internals because I mainly mean to have a compare-if on the 1st step, not focus on macro.
I also know that if won't fit, only in order to find a way.
Post 05 Aug 2016, 16:59
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 05 Aug 2016, 17:51
You can use match for preprocessor conditionals.
Post 05 Aug 2016, 17:51
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 06 Aug 2016, 03:02
revolution wrote:
You can use match for preprocessor conditionals.

I already know that. I just hadn't known how to actually do it.
I found that
Code:
rept 1 t:a-b{ match -u, t \{ ... \} }    
matches when a-b<0 or to say a<b, but it still seems unreadable?


Last edited by l4m2 on 06 Aug 2016, 03:10; edited 1 time in total
Post 06 Aug 2016, 03:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 06 Aug 2016, 03:09
l4m2 wrote:
revolution wrote:
You can use match for preprocessor conditionals.

I already know that. I just hadn't known how to actually do it.
If you had stated that in the first post then we could have helped you better. We are not mind readers (or at least I am not) so it is difficult to know what you want when you only post 5 lines of code with no explanation.
l4m2 wrote:

I found that
Code:
rept 1 t:a-b{ match -u, t \{ ... \} }    
matches when a-b<0 or to say a-b, but it still seems unreadable?
Perhaps a way to make it more understandable is to put comments in the code the explain what it is intended to do. Wink

Perhaps the most useful, and most ignored, part of assembly code is the semi-colon character used to introduce comments. Razz
Post 06 Aug 2016, 03:09
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 21 Aug 2016, 01:29
revolution wrote:
Perhaps a way to make it more understandable is to put comments in the code the explain what it is intended to do. Wink

Perhaps the most useful, and most ignored, part of assembly code is the semi-colon character used to introduce comments. Razz
Comments should be the last way to make understandable code. Try macroing it
Post 21 Aug 2016, 01:29
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 21 Aug 2016, 23:08
l4m2 wrote:
Comments should be the last way to make understandable code. Try macroing it

Comments make it easier to understand the code for other but also for yourself.
Whenever you tried to understand own code written years ago you would make the experience that comments are absolutely helpful and appreciated. Even just for yourself. The time you save in sparing comments you will invest double or triple or even more in finding bugs in your code later. Wink
Post 21 Aug 2016, 23:08
View user's profile Send private message Send e-mail 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.