flat assembler
Message board for the users of flat assembler.

Index > Main > Problem with string conversion

Author
Thread Post new topic Reply to topic
pfranz



Joined: 13 Jan 2007
Posts: 116
Location: Italy
pfranz 22 Oct 2023, 15:05
This doesn't work for me:
Code:
 macro show par {display `par}
show [hello]    
Post 22 Oct 2023, 15:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 22 Oct 2023, 15:41
Each symbol needs its own backtick (`)
Code:
macro show par {
        irps p,par \{
                display \`p
        \}
}
show [hello]    
Post 22 Oct 2023, 15:41
View user's profile Send private message Visit poster's website Reply with quote
pfranz



Joined: 13 Jan 2007
Posts: 116
Location: Italy
pfranz 22 Oct 2023, 18:00
Sorry, didn't see it was moved to Main (why?).
Quote:
Each symbol needs its own backtick (`)

What does it mean? I see that you are using a workaround: using irps that doesn't seem to have the problem.
But still I think that the macro should convert the symbol properly.
Post 22 Oct 2023, 18:00
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 22 Oct 2023, 18:23
There are three symbols "[", "hello", and "]".

Using irps isn't a workaround it is a requirement to apply ` to each symbol. Otherwise only the first symbol is converted to a string and the final two symbols can't be displayed as they are.

I moved to "main" because this isn't about the internal details of the assembler, but rather it is about writing the code it assembles.
Post 22 Oct 2023, 18:23
View user's profile Send private message Visit poster's website Reply with quote
pfranz



Joined: 13 Jan 2007
Posts: 116
Location: Italy
pfranz 22 Oct 2023, 19:23
I thought the symbol was the argument name.
This problem comes from passing values by reference to functions, such as [PointerToX], and trying to display them inside macro calls for debugging.
[PointerToX] is a single parameter, like ValueX, so should be a single symbol to be converted to string, correct?
Post 22 Oct 2023, 19:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 22 Oct 2023, 19:34
A parameter is not a symbol. They are different.

Macro parameters are separated by commas (,). Symbols are any run of characters separated by:
Code:
symbol_characters db 27
 db 9,0Ah,0Dh,1Ah,20h,'+-/*=<>()[]{}:,|&~#`;\'    
This can be found in tables.inc.
Post 22 Oct 2023, 19:34
View user's profile Send private message Visit poster's website 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.