flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > ? conditional preprocess

Author
Thread Post new topic Reply to topic
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 17 Mar 2006, 18:05
Hi,
Is it possible to 'catch' 'eqtype 0.0' in conditional preprocess and how?
thanks
Post 17 Mar 2006, 18:05
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 17 Mar 2006, 18:06
No, it's not possible. "0.0" is for preprocessor just the "word", like "some.label".
Post 17 Mar 2006, 18:06
View user's profile Send private message Visit poster's website Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 17 Mar 2006, 20:20
Interesting...
with 'eqtype 0.0' i 'catch' float numbers and actuality me need this one.
Post 17 Mar 2006, 20:20
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 17 Mar 2006, 20:42
What is your purpose? Maybe you can move the "weight" of the processing into the assembler module?
Post 17 Mar 2006, 20:42
View user's profile Send private message Visit poster's website Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 17 Mar 2006, 22:33
My purpose is, to put float numbers(constants) into individual data segment.
for example:
fld 5.56
fld 4.56
will be assemble:
fld qword[float_segment]
fld qword[float_segment+8]
...
float_segment:
dq 5.56
dq 4.56
You hint me how to do that with str data.
Quote:
Maybe you can move the "weight" of the processing into the assembler module?
what you mean?
Post 17 Mar 2006, 22:33
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 17 Mar 2006, 23:04
For this purpose you don't really need to determine exactly whether it's float, I think, as any FLD of this kind
Code:
fld 5.56
fld xyz    

can be treated the same way. It can look like this:
Code:
macro fld value
{
  PROCESSED equ 0
  match first rest,value
  \{ fld value
     PROCESSED equ 1\}
  match =0, PROCESSED
  \{ local ..float
     floats_list equ floats_list,..float,value
     fld qword [..float] \}
}

macro floats dummy,[label,value] { label dq value }

macro floats_data { match list,floats_list \{ floats list \} }


xx = 4.1

fld 2.0
fld dword [0]
fld xx

floats_data    

Note that this way it works also with the constant name.


As for moving the "weight" of processing into assembler module, I did mean something like (this time "floats_data" has to be put before the instructions, just the opposite of the above):
Code:
macro floats_data
{
  floats_data:
   times floats_count dq 0.0
   floats_current = 0
}

macro fld value
{
  if value eqtype 1.0
   if floats_count > floats_current ; we need to check this because in intermediate passes the floats data area may not have been properly allocated yet
    virtual at 0
     dq value
     load float_value qword from 0
    end virtual
    store qword float_value at floats_data+(floats_current)*8
   end if
   fld qword [floats_data+(floats_current)*8]
   floats_current = floats_current+1
  else
   fld value
  end if
}

macro .end { floats_count = floats_current }


floats_data

start:

fld 3.14
fld dword [0]

.end    

Note that preprocessor is used here only for macro "containers", everything inside is the assembler's scripting language.
Post 17 Mar 2006, 23:04
View user's profile Send private message Visit poster's website Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 18 Mar 2006, 11:59
I begun on similar of the second way, and i had a promblem. Now I see why. I will continue onto first way.
thanks again
Post 18 Mar 2006, 11:59
View user's profile Send private message Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 19 Mar 2006, 18:02
I will continue the topic with my next 'problem'. It's a my pushd macro object. I haven't an idea how detect in conditional preprocess float constant, except method as win32ax.inc(using prefix like 'double'). is it an ideas to detect it, without use the prefix?
Second question is - what symbols or group from symbols - 'match' can't detected, except ';' ?
thanks

_________________
regards
Post 19 Mar 2006, 18:02
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 19 Mar 2006, 18:23
"double" is not a prefix for float, it is a prefix for 64-bit value. The floats can be 32-bit, 64-bit or 80-bit, for example when using OpenGL calls you, some of them require 32-bit floats, while other 64-bit. But when you've got, say, a 64-bit float, there's no really difference between it and 64-bit integer - they are both just a 64-bit value. So "double" will work with the 1.0 value, and it will also work with the 1234h or 'ABCDEDFG' (well, that's by the way what I see as the beauty of assembly language; every kind of data is just a sequence of bits and assembler doesn't hide it from you).

As for the symbol characters, they are listed in section 1.2.1 of manual. Any other character can either be a part of name symbol, or is a whitespace or comment. And there is also a backslash, which is treated specially depending whether it is on end of line, or not. When it is not at end of line, it takes whatever symbol follows it and composes with it into new one symbol.
Post 19 Mar 2006, 18:23
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.