flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [feature request] "when" preprocessor(assembler?)

Author
Thread Post new topic Reply to topic
dead_body



Joined: 21 Sep 2005
Posts: 187
Location: Ukraine,Kharkov
dead_body 28 Mar 2006, 10:08
Code:
tmp = 0
when tmp > 0
  db tmp
end when
inc ecx
...
tmp = 1;after here 'when tmp > 0' will be assembled.
...
tmp = 500;'when' will not be assembled, because it was already done.
;if there no tmp in code 'when' will not be assembled.
    

with such directive preprocessor will be more powerful i think.
and if preprocessor will have an 'order' directive, it will be the most powerful thing.
order directive:
Code:
order 1{tmp = tmp + 1};will be preprocessed after 'tmp = 0'
order 0{ tmp = 0};have high order to preprocess
    

i know that add such directives is a very hard work, because there are not so simple, and with them, there will be many complex situaitions with order of preprocessing.
Maybe i am not right and these directives will not be in use at all Embarassed
Post 28 Mar 2006, 10:08
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 28 Mar 2006, 10:43
Preprocessor should not interact in any way with the assembler construct's (like =). Also any applications I can imagine of such thing can be implemented in other ways using the standard techniques.

I also suggest to follow my Understanding fasm article as I continue expanding it. At this moment it has a higher priority for me to well document all the existing features and tricks instead of thinking out any new ones.
Post 28 Mar 2006, 10:43
View user's profile Send private message Visit poster's website Reply with quote
dead_body



Joined: 21 Sep 2005
Posts: 187
Location: Ukraine,Kharkov
dead_body 28 Mar 2006, 14:30
maybe in future, when all tricks of fasm will be document this command will be in use. But it is too difficult to make it i think.
Code:
format PE GUI 4.0
include "C:\fasm\INCLUDE\WIN32AX.INC"

;normal priority is 0
;1,2,3... is higher priority
;-1,-2,-3... is lower priority
;first pass to find highest order.
;second pass to do it.
;then third pass ...
.code
__EntryPoint:
    order 4 {const1 equ 123}
    order -1 {mov eax,const1};mov eax,5
    order 3 {const1 equ 321}
    mov eax,const1      ;mov eax,321
    order 4 {mov eax,const1};mov eax,123
    const1 equ 5;with order 0
    ret
.end __EntryPoint    


http://flatassembler.net/docs.php?article=ufasm
is a very good article. thank you fo it.
Post 28 Mar 2006, 14:30
View user's profile Send private message Reply with quote
chris



Joined: 05 Jan 2006
Posts: 62
Location: China->US->China->?
chris 29 Mar 2006, 09:08
to dead_body:
the assembler directive 'if' is what you were looking for in the first example.
Code:
if tmp>0 
db tmp
end if
    

as for the second one, I didn't see any point here in your example code - it's just reducing the readablity of your code. Maybe you could construct some more convincing examples to justify your request. Wink
Post 29 Mar 2006, 09:08
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 29 Mar 2006, 21:38
chris: no it isn't, he is looking to define that block when tmp changes. not if tmp is >0 at that time. the idea is the first time it changes above zero it will execute that statement (db tmp).
Post 29 Mar 2006, 21:38
View user's profile Send private message Reply with quote
chris



Joined: 05 Jan 2006
Posts: 62
Location: China->US->China->?
chris 30 Mar 2006, 03:08
UCM wrote:
chris: no it isn't, he is looking to define that block when tmp changes. not if tmp is >0 at that time. the idea is the first time it changes above zero it will execute that statement (db tmp).


maybe, I was just trying to suggest another approach, like:
Code:
macro deftmp
{
  if tmp>0&tmp<500
    db tmp
  end if
}

tmp=0
deftmp

tmp=1
deftmp

tmp=500
deftmp
    

Is this what dead_body was trying to do?
Post 30 Mar 2006, 03:08
View user's profile Send private message Reply with quote
dead_body



Joined: 21 Sep 2005
Posts: 187
Location: Ukraine,Kharkov
dead_body 30 Mar 2006, 11:07
i will write after some time(maybe days), what i mean.
Post 30 Mar 2006, 11:07
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.