flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > This is bug or feature of fasm1 ( "+-1.0" error )

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 785
Location: Russian Federation, Sochi
ProMiNick 22 Feb 2023, 20:48
Code:
if +(num) relativeto 0     

if someone expect negate floats as inputs instead of num - he must enclose num in braces (), otherwise compile error.
so it is a feature or a bug? (Nothing is bug if there ways that end programmer could code exactly that what it want, no matter if coding form of working solution is not intuitive on first sight).

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 22 Feb 2023, 20:48
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20016
Location: In your JS exploiting you and your system
revolution 22 Feb 2023, 20:55
Works for me:
Code:
if -1.0 relativeto 0
end if    
Post 22 Feb 2023, 20:55
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 882
Location: Russia
macomics 22 Feb 2023, 21:11
Code:
use64
define numn -1.0
define nump  1.0

if +numn relativeto 0
end if
if +nump relativeto 0
end if    

Code:
$ fasm -m 10240 ./tests.asm
flat assembler  version 1.73.30  (10240 kilobytes memory)
./tests.asm [9]:
if +numn relativeto 0
processed: if+-1.0 relativeto 0
error: reserved word used as symbol.    


Code:
use64
define numn -1.0
define nump  1.0

if +(numn) relativeto 0
end if
if +nump relativeto 0
end if    

Code:
$ fasm -m 10240 ./tests.asm
flat assembler  version 1.73.30  (10240 kilobytes memory)
1 passes, 0 bytes.    
Post 22 Feb 2023, 21:11
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20016
Location: In your JS exploiting you and your system
revolution 22 Feb 2023, 21:23
You don't need the + prefix. It does nothing useful.
Code:
if numn relativeto 0    
The error is the same for any use of +- with floats.
Code:
dd +-1.0  ; error: reserved word used as symbol.    
Post 22 Feb 2023, 21:23
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 785
Location: Russian Federation, Sochi
ProMiNick 23 Feb 2023, 00:15
revolution wrote:
You don't need the + prefix. It does nothing useful

revolution, see win32ax.inc pushd override
Code:
macro pushd value
{ match first=,more, value \{ \local ..continue
   call ..continue
   db value,0
   ..continue:
   pushd equ \}
  match pushd =addr var,pushd value \{ \local ..opcode,..address
   if +var relativeto 0 | +var relativeto $    
for some reason it was needed
and with negate float passed to invokes with win32ax.inc included I could crash compilation process.
in case of win32a.inc negate floats passed to invokes OK.

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 23 Feb 2023, 00:15
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20016
Location: In your JS exploiting you and your system
revolution 23 Feb 2023, 00:23
You can use = instead of equ
Code:
numn = dword -1.0 ; or qword    
Post 23 Feb 2023, 00:23
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 785
Location: Russian Federation, Sochi
ProMiNick 23 Feb 2023, 00:51
so, what thou suggest revolution for others in case of using negative floats passed to invokes with win32ax.inc includes?
1.Don`t use them together.
2. patch pushd override manualy
3. patch fasmcore that atleast unary+- works on floats
Post 23 Feb 2023, 00:51
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20016
Location: In your JS exploiting you and your system
revolution 23 Feb 2023, 01:27
I think it is a bug because it is inconsistent.
Code:
db +-1          ; this is fine
dq +-1.0        ; error: reserved word used as symbol.    
But for the meantime, until, or if, it is fixed you have options:
Code:
numn equ (-1.0)
define numn (-1.0)
numn = dword -1.0
numn = qword -1.0
pushd (-1.0)
invoke func, (-1.0), foo, bar    
Post 23 Feb 2023, 01:27
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8311
Location: Kraków, Poland
Tomasz Grysztar 23 Feb 2023, 08:03
In fasm 1 floats are not allowed to be a part of an arithmetic expression. A sign character is handled as a special case.
Post 23 Feb 2023, 08:03
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: 20016
Location: In your JS exploiting you and your system
revolution 23 Feb 2023, 08:59
Tomasz Grysztar wrote:
In fasm 1 floats are not allowed to be a part of an arithmetic expression. A sign character is handled as a special case.
Unary + and - can be accumulated into the final sign.
Code:
apple_pie = +-+-3.141592653589793    
Ignore all +, negate for each -.

Why does pushd macro have the + prefix?
Post 23 Feb 2023, 08:59
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8311
Location: Kraków, Poland
Tomasz Grysztar 23 Feb 2023, 09:52
revolution wrote:
Why does pushd macro have the + prefix?
This is an idiom I've been using to allow RELATIVETO to be used also with register arguments. It was a habit, so I'm not sure if it's really necessary here.
Post 23 Feb 2023, 09:52
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.