flat assembler
Message board for the users of flat assembler.

Index > Main > [fasmg] fwd-ref calm inx using calminstruction?.xx

Author
Thread Post new topic Reply to topic
fabbel



Joined: 30 Oct 2012
Posts: 103
fabbel 22 May 2025, 14:33
Hi (again) Tomasz
.. just stumbled upon this ... not a big deal, but just wondering if this is intended / inherent limitation to keep in mind ?

the below snippet fails:
Code:
calminstruction calminstruction?.init? var*, val:0
        compute val, val
        publish var, val
end calminstruction

test  10

calminstruction test arg*
        local _0xA
        init _0xA, 0x0A

                check arg = _0xA
                jyes @match

                display 'NOT matched' bappend 0x00A0D
                exit
        @match:
                display 'Matched !' bappend 0x00A0D
end calminstruction
    

yielding error
Quote:
symbol 'test:_0xA' is undefined or out of scope.

.. but actually assembles fine if moving the call 'test 10' after the definition of calminstruction test ...
Post 22 May 2025, 14:33
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8434
Location: Kraków, Poland
Tomasz Grysztar 22 May 2025, 14:50
Variable symbols cannot be forward-referenced, and CALM LOCAL forces "_0xA" to become such variable.

A more detailed explanation: as mentioned in the manual, such local symbol it is at first (during the definition of CALM instruction) "assigned a defined but unusable value", and this value is then replaced by definition-time INIT macro.
Post 22 May 2025, 14:50
View user's profile Send private message Visit poster's website Reply with quote
fabbel



Joined: 30 Oct 2012
Posts: 103
fabbel 22 May 2025, 14:54
ok got it. tx
Post 22 May 2025, 14:54
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.