flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Implementing conditionals using match

Author
Thread Post new topic Reply to topic
nisargshah95



Joined: 23 Jun 2016
Posts: 7
Location: India
nisargshah95
I have the following code snippet
Code:
LANG equ 1 ; or 2
stmt1 db "statement 1",0
stmt2 db "statement 2",0
    

I want to use stmt1 or stmt2 depending on whether LANG is set to 1 or 2. I decided to use 'match' for this -
Code:
LANG equ 1
macro stmt
{
        match =1, LANG \\{ db 'stmt1',0 \\}
        match , LANG \\{ db 'stmt2',0 \\}
}    

The above code resides inside another code block. When I compile it, I get
Quote:
macro stmt
error: incomplete macro.

Where am I going wrong?
Post 09 Jul 2016, 05:03
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
nisargshah95
Quote:
The above code resides inside another code block

That's one of the problems. It depends on what exactly is around the provided snippet, but most probably your escaping (the backslashes) is applied incorrectly. In particular the singly nested match-macroblocks should not have double escaping, because the braces will remain singly escaped after the expansion of the macro stmt, and will not be recognized as the beginning and ending of the macroblocks. On the other hand, if you have a macroblock around that snippet then you're missing escaping of the "macro stmt" braces.

_________________
Faith is a superposition of knowledge and fallacy
Post 09 Jul 2016, 17:52
View user's profile Send private message Reply with quote
nisargshah95



Joined: 23 Jun 2016
Posts: 7
Location: India
nisargshah95
Quote:
On the other hand, if you have a macroblock around that snippet then you're missing escaping of the "macro stmt" braces.

Yes I do have another macro block around the snippet. Now it works. Thanks! Very Happy
Post 13 Jul 2016, 03:05
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.