flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [solved] fasm and fasmg float+float

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 06 Mar 2020, 07:20
I have binary file.
Code:
p EQU 5.0
dd 10.0
dd 20.0
dd 30.0
dd 40.0
dd 50.0
dd 60.0
dd 70.0
dd 80.0
dd 90.0
dd 100.0
    

Some time i need re calculate values. And i must rewrite hands all this data !
Code:
dd 15.0
dd 25.0
dd 35.0
dd 45.0
dd 55.0
dd 65.0
dd 75.0
dd 85.0
dd 95.0
dd 105.0
    


How auto do this in fasmg ? Use macro or some else ?
Post 06 Mar 2020, 07:20
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 06 Mar 2020, 07:31
I try this work
rept 5 n:0 {
dd 56.0,BortX,BortUpY,-n#.0,ScalBort
dd 56.0,BortX2,BortUpY,-n#.0,ScalBort
}

But this not work error
rept 5 n:0 {
dd 56.0,BortX,BortUpY,-n*5#.0,ScalBort
dd 56.0,BortX2,BortUpY,-n*5#.0,ScalBort
}
Post 06 Mar 2020, 07:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 06 Mar 2020, 08:24
Dealing with binary floating point numbers is tricky. You need to separate the mantissa from the exponent, then do the addition, adjust the exponent and mantissa, and recombine into floating point format.

If would likely e easier to do everything in integers first and then add the final ".0" as the final step and let the assembler convert it to floating point.
Post 06 Mar 2020, 08:24
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 06 Mar 2020, 08:33
Roman wrote:
I try this work
rept 5 n:0 {
dd 56.0,BortX,BortUpY,-n#.0,ScalBort
dd 56.0,BortX2,BortUpY,-n#.0,ScalBort
}

But this not work error
rept 5 n:0 {
dd 56.0,BortX,BortUpY,-n*5#.0,ScalBort
dd 56.0,BortX2,BortUpY,-n*5#.0,ScalBort
}
You mentioned fasmg, but then you provided a sample in fasm 1 syntax. Which one do you mean? This works with fasmg:
Code:
rept 5 n:0
dd 56.0,BortX,BortUpY,-n*5#.0,ScalBort
dd 56.0,BortX2,BortUpY,-n*5#.0,ScalBort
end rept    
but it is not possible with fasm 1 - there you would need a trick like revolution mentioned.
Post 06 Mar 2020, 08:33
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 06 Mar 2020, 08:40
And in fasm where I mentioned doing the computations in integers:
Code:
rept 5 n:0 {
        rept 1 m:n*5 \{
                dd 56.0,BortX,BortUpY,-m\#.0,ScalBort
                dd 56.0,BortX2,BortUpY,-m\#.0,ScalBort
        \}
}    
Untested though. Try it.
Post 06 Mar 2020, 08:40
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 06 Mar 2020, 09:01
Thanks work !
Post 06 Mar 2020, 09:01
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 06 Mar 2020, 09:03
But not work this:
Code:
rept 5 n:0 {
        rept 1 m:n*293 \{
                dd 56.0,BortX,BortUpY,-m\#.n,ScalBort
                dd 56.0,BortX2,BortUpY,-m\#.m,ScalBort
        \}
}     
    

Fasm get error reserved word used as symbol
Post 06 Mar 2020, 09:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 06 Mar 2020, 09:13
You have to combine the dot and the label with a hash:
Code:
dd 56.0,BortX,BortUpY,-m\#.\#n,ScalBort    
Post 06 Mar 2020, 09:13
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 06 Mar 2020, 09:16
Big thanks for you help !
I create 3d level for my Directx 12 game shooter.

This very help me fast and easy create 3d level float data.
Post 06 Mar 2020, 09:16
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.