flat assembler
Message board for the users of flat assembler.

Index > Main > [fasmg] Using "?" with arrange

Author
Thread Post new topic Reply to topic
Calanor



Joined: 19 Jul 2015
Posts: 32
Location: Sweden
Calanor
I'd like to construct a macro from within CALM. Say, something like this:
Code:
arrange cmd, =macro t#=globalblock#s    
However, I'd also like to make the macro case-insensitive, but adding "#=?" (or "#?" for that matter) at the end won't yield the results I hoped for. In fact, it actually seems to name the macro to [name] followed by a literal "?". If I call the macro by adding a "?" at the end of the name, fasmg will enter it. This seems pretty weird - is this really working as intended?
Post 25 Jan 2021, 23:48
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7938
Location: Kraków, Poland
Tomasz Grysztar
Adding "?" at the end of identifier on use is just another way of calling the case-insensitive symbol:
Code:
macro show tokens&
        display `tokens,13,10
end macro

calminstruction try t,s
        arrange cmd, =macro t#=globalblock#s?
        assemble cmd
        arrange cmd, =show cmd
        assemble cmd
        arrange cmd, =end =macro
        assemble cmd
end calminstruction

try A,0

; these all call the same macro:
Aglobalblock0
aglobalblock0
aglobalblock0?    
(Note: this works the same if you use "#?" or even "#=?" instead of plain "?" at the end of that ARRANGE, they make no difference here.)

When you have a case-insensitive symbol, you can always to refer to it directly by using an identifier followed by "?". This allows, for example, to call the case-insensitive macro even when there is another, case-sensitive one that would override it for the specific combination of characters that you used:
Code:
macro A#globalblock#1?
        display '1: case insensitive',10
end macro

macro A#globalblock#1
        display '2: case sensitive',10
end macro

Aglobalblock1   ; calls the second one
aglobalblock1   ; calls the first one
Aglobalblock1?  ; calls the first one    
Post 26 Jan 2021, 08:30
View user's profile Send private message Visit poster's website Reply with quote
Calanor



Joined: 19 Jul 2015
Posts: 32
Location: Sweden
Calanor
Well, that's interesting! Thanks for the information, Tomasz. I had no problems running your code, so there's something odd going on at my end.

To clarify: as soon as I add "#=?", "#?" or "?" at the end of the line, I get a cascade of error messages. The line that constructs the macro does show up in the error log, but it looks perfectly fine. I'm quite confused, but I'll experiment a bit and see if I can figure things out before posting a wall of code.
Post 26 Jan 2021, 11:56
View user's profile Send private message Reply with quote
Calanor



Joined: 19 Jul 2015
Posts: 32
Location: Sweden
Calanor
Tomasz: Oh, I've realised what went wrong. The problem was when I later use purge on the macro defined in the CALM-instruction. I didn't include the "?" when purging, which obviously was a bad idea! It's mentioned in the manual that symbols can be defined/used in the way you did here, but for some reason I keep associating symbols with "variables". Rolling Eyes I better study my code in case I've made any similar mistake somewhere. Thanks again Tomasz!
Post 26 Jan 2021, 13:34
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.