flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Compiler Internals > fasmg suggestion to expand expressions with logical ops

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 473
Location: Belarus
fasmg suggestion to expand expressions with logical ops
So that instead of

Code:

if a = VALUE
  b = 1
else
  b = 0
end if
c = b * d



it would be possible to do something like

Code:

c = (a == VALUE) * d



Tomasz, what do you think of it?
Post 19 Mar 2017, 23:12
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6435
Location: Kraków, Poland
It could be possible to create the operators that would work in numeric expressions and compute logical operation with numeric (1 or 0) result, but I feel that it could be a bit confusing when we also have an additional class of operators that can be used to build actual logical expressions. fasm's language uses a design when these kinds of expressions are separate entities, and numeric expressions are themselves elements that a logical expression may be built from (like numbers are elements to built numeric expression). I feel that this approach plays well with my general view of fasm's syntax as "one statement per line"-like language. In fasmg I have kept the expression evaluation as close to fasm's as possible (in most places it is fully compatible).
Post 20 Mar 2017, 09:57
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: 14924
Location: 6EQUJ5
Sometimes I think people want fasm(g) to be a C clone. Sad

The terrible double/single equals and the amount of bugs it has caused in C code are innumerable.

Code:
;C style
if (x = 1) {  ;OMG I forgot to use ==
  do something
}

Post 20 Mar 2017, 11:24
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6435
Location: Kraków, Poland

revolution wrote:
Sometimes I think people want fasm(g) to be a C clone. Sad

It is worth to add that MASM's syntax, which is what fasm tried to distance itself from, was at least partially designed to resemble C. The MASM's semantics of square brackets were inherited from C and were so often hated that it led to the creation of TASM's "ideal mode" and NASM's syntax.
Post 20 Mar 2017, 12:00
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 473
Location: Belarus

revolution wrote:
Sometimes I think people want fasm(g) to be a C clone. Sad


No, I don't want a C clone and I used == as the first that came to mind just to express the idea easy to follow -- being able to wrap 3 or more if-else statements into one-line expression
Post 20 Mar 2017, 12:16
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14924
Location: 6EQUJ5

zhak wrote:
... being able to wrap 3 or more if-else statements into one-line expression

Yeah, this what I see as the C way of doing things. Make the logic as dense as possible to confuse the reader and hide more bugs. Along with the pattern of single character variable names that makes it even more obscure as to what is intended. Many C coders do this (either intentionally or not) and then end up confusing themselves later. I guess I just don't want to see assembly head down the same path. Sad
Post 20 Mar 2017, 12:23
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 473
Location: Belarus
It could lead to faster source processing and decreasing compilation time. Ain't it good?
Post 20 Mar 2017, 12:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14924
Location: 6EQUJ5

zhak wrote:
It could lead to faster source processing and decreasing compilation time. Ain't it good?

I think that is totally the wrong metric to use, even if it were to be true. It only takes one bug, with all the effort to fix it, and you've lost all those speed gains many times over.
Post 20 Mar 2017, 12:35
View user's profile Send private message Visit poster's website Reply with quote
guignol



Joined: 06 Dec 2008
Posts: 258
Could use 'isof'.
Want for speedy application compilation is the indication of bad design.
Post 20 Mar 2017, 13:57
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.