flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > CALM CALL instruction |
Author |
|
fabbel 20 Apr 2023, 12:16
. or even different from simply
Code: calminstruction another_calm_inx calm_inx end calminstruction |
|||
20 Apr 2023, 12:16 |
|
Tomasz Grysztar 20 Apr 2023, 13:58
CALL was implemented on a request from one of the early adopters of CALM, purely for performance reasons. However, they way it is implemented, it also allows to do some small tricks that are not possible through a normal ASSEMBLE route.
When a macro is called through a standard assembly, the arguments are always symbolic values - pieces of text cut from the original assembled line. But when giving values to CALL variables, you can pass any kind of value, not necessarily symbolic. This allows for a further performance gain, when you pass a numeric/polynomial value directly, but may also cause some subtle effects in cases where the type of value matters: Code: calminstruction demo value* local a, b match a+b, value jyes two emit 1, value exit two: emit 1, a emit 1, b exit end calminstruction calminstruction test0 expr local cmd arrange cmd, =demo expr assemble cmd end calminstruction calminstruction test1 expr compute value, expr call demo, value end calminstruction test0 2+3 test1 2+3 ; fails, because MATCH cannot be applied to numeric value The fact that CALL makes it possible for an argument to come with a non-symbolic value is the reason why in the experimental branch I added a __TEXT operator that allows CHECK command to determine whether a variable has a symbolic value. And CALL command is also going to fail when the target instruction is not CALM itself. In short: the use of CALL is optional, when you need your macros to work faster, and then it should be used carefully. fabbel wrote: . or even different from simply This helped me remember another difference: with CALL the reference to target instruction is resolved at definition time. At the run-time ASSEMBLE may see and execute an instruction with the same name from a different namespace, depending on context, but compiled CALL command always refers to the same symbol, fixed at the time of definition/compilation. |
|||
20 Apr 2023, 13:58 |
|
fabbel 21 Apr 2023, 14:09
Hi, Tx for detailed explanation.
Another question though... : can CALL command be used to call a labelled calminstruction ? what is the syntax to use then ? |
|||
21 Apr 2023, 14:09 |
|
Tomasz Grysztar 21 Apr 2023, 14:20
No, there is no such variant. It is more natural for the instructions that you call to be written specifically for that purpose.
|
|||
21 Apr 2023, 14:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.