flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar 06 May 2025, 06:04
MATCH is not the right tool. For fasmg, just like for fasm, a quoted string is a complete, indivisible token (see the fundamental syntax rules for a short description of fasmg's tokenization). Quoted string tokens, just like special characters, are matched literally (in this case it means that the content of the string must be the same), so "=" modifier has no additional effect on them.
|
|||
![]() |
|
bitRAKE 06 May 2025, 06:17
EQTYPE is the operator:
Code: if val eqtype "" display "val is a string", 10 end if If val can be anything then some corner cases need to be excluded. This thread should be useful. |
|||
![]() |
|
Tomasz Grysztar 06 May 2025, 08:45
bitRAKE wrote: EQTYPE is the operator: Code: assert 'x' eqtype string 32 assert 'x' eqtype 13 bappend 10 assert 'x' eqtype 1 bswap 4 |
|||
![]() |
|
Jessé 06 May 2025, 12:26
I've got some success while trying with ' if something eqtype "" '. Could not diferentiate single or double quoted strings yet, but this is not a problem, because I have noticed that strings are just strings to fasmg anyway. And that's fine for the application I will use it.
The only issue I had is when an invalid token is to be tested, match just doesn't match and ' if testme eqtype "" ' fails with an error. Also not a problem at all, because invalid tokens has no meaning in any context, I suppose. |
|||
![]() |
|
Jessé 07 May 2025, 12:44
Another related topic: can I differentiate a label from a number in a macro?
Every test I do, I find that the assembler (at macro level) defines both types equally. |
|||
![]() |
|
dosmancer 07 May 2025, 15:45
Jessé wrote: Another related topic: can I differentiate a label from a number in a macro? Maybe like this: Code: define labels struc (label) ? line& define labels.label . line end struc label1: calminstruction test var transform var, labels jno not_label display "Is a label" bappend 13 bappend 10 exit not_label: display "Not a label" bappend 13 bappend 10 end calminstruction test label1 test 55 I'm not sure if it's a good solution but it adds labels to a labels namespace then uses transform and if the transform occurred then it means var was found in the labels namespace. |
|||
![]() |
|
Jessé 07 May 2025, 22:01
Interesting, I'll test it.
Actually, this will benefit my fastcall project, because I can give a 'memory operand' treatment to a label, and a 'value parameter' to a number. Thanks. ![]() P.S.: it worked! Nice! I'll test it even further and adapt the concept to my project. ![]() |
|||
![]() |
|
dosmancer 07 May 2025, 23:47
Jessé wrote: Interesting, I'll test it. Awesome. Note that there is another way labels can be created, with the label keyword so that also needs to be handled: Code: define labels struc (label) ? line& define labels.label . line end struc ; without this label2 and label3 will show "Not a label" macro label? line& match a:b, line define labels.a else define labels.line end match label line end macro calminstruction test var transform var, labels jno not_label display "Is a label" bappend 13 bappend 10 exit not_label: display "Not a label" bappend 13 bappend 10 end calminstruction label1: label label2 label label3:byte test label1 test label2 test label3 test 55 |
|||
![]() |
|
Jessé 08 May 2025, 04:03
Is there a way to export the result to a global variable or something similar?
Ex.: _is_label = 0 test label1 ; _is_label = 1 if is label, _is_label = 0 if not. I have tried here, without success for now. Edit: I've got it right. Just a typing error (endif instead of end if). It's late here in Brazil, and I waiting for a feedback on my work while doing it. Edit²: by the way, this is my working version (don't know if it could be done better): Code: define labels struc (label) ? line& define labels.label . line end struc label1: __is_label_ = 0 calminstruction test_para var transform var, labels jno not_label ; display "Is a label" bappend 13 bappend 10 compute __is_label_, 1 exit not_label: compute __is_label_, 0 ; display "Not a label" bappend 13 bappend 10 end calminstruction Also, I'll include your statement about the label directive. |
|||
![]() |
|
Tomasz Grysztar 08 May 2025, 11:41
Jessé wrote: Edit²: by the way, this is my working version (don't know if it could be done better) Code: define labels struc (label) ? line& define labels.label . line end struc label1: TRUE := 1 FALSE := 0 calminstruction (out) test_para var transform var, labels jno not_label publish out, TRUE exit not_label: publish out, FALSE end calminstruction is_label test_para label1 if is_label display "Is a label",13,10 else display "Not a label",13,10 end if PS. For a check done with TRANSFORM it would be more appropriate to call it "contains_label" instead of "is_label". |
|||
![]() |
|
Tomasz Grysztar 08 May 2025, 14:37
Also please note that the feature of fasmg that was actually intended to help with distinguishing labels from raw numbers is the ORG directive with base containing terms defined with ELEMENT. See the second half of "How are the labels processed?" section of the auxiliary documentation. Look for the "if the labels need to be differentiated from absolute values" phrase and all the following examples.
|
|||
![]() |
|
Jessé 08 May 2025, 23:36
Nice, I had missed this part of the famsg manual.
Already saved it so I can study it. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.