flat assembler
Message board for the users of flat assembler.

Index > Main > I read docs about definite, but not understood all functions

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1710
Roman 30 Nov 2022, 08:47
In docs I found minimum info about definite. And no examples how using definite.
I want learn more features and tricks with definite.
I feel something unusual in definite.
Post 30 Nov 2022, 08:47
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 30 Nov 2022, 09:44
See the thread where this feature was announced: https://board.flatassembler.net/topic.php?t=21058

In short: DEFINITE is very similar to DEFINED, except it does not forward-reference, so you can check whether a symbol has been defined earlier in the source (while DEFINED would consider if the symbol ends up defined anywhere, even further down the text).
Code:
A = 1

assert defined A
assert defined B
assert ~ defined C

assert definite A
assert ~ definite B
assert ~ definite C

B = 2    

A thing of note for both DEFINED and DEFINITE is that both operate on numeric (as opposed to symbolic) constants/variables. The variables created with EQU or DEFINE are replaced with their corresponding text before the expression containing DEFINED/DEFINITE is interpreted. So if you use DEFINED/DEFINITE with a symbol name that is assigned a value with EQU or DEFINE, you end up checking what is inside the symbolic value.
Code:
A = 1

S equ A

assert defined S

S equ C

assert ~ defined S    
All these examples work the same with fasmg as with fasm 1.
Post 30 Nov 2022, 09:44
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1710
Roman 30 Nov 2022, 12:02
I found this.
Code:
if ~ definite Module
    Module = 1 ; define only if it has not already been defined earlier
end if       

How I understood definite using for someName = some value.
And not using for EQU
Post 30 Nov 2022, 12:02
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 30 Nov 2022, 13:09
Roman wrote:
How I understood definite using for someName = some value.
It also works for labels, because in fasm labels are just a kind of numeric constant ("foo:" means the same as "foo := $" in fasmg syntax).
Post 30 Nov 2022, 13:09
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1710
Roman 02 Dec 2022, 07:14
Interesting idea. Get number from lLoop8
Code:
lLoop8:
          inc eax
if  definite lLoop8
    Somehow get from lLoop8 number 8 to Reg ecx
cmp eax,ecx
Jb lLoop8
end if 
    
Post 02 Dec 2022, 07:14
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.