flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > match inside struc

Author
Thread Post new topic Reply to topic
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 31 Jul 2020, 11:22
Hi
I have names like
Code:
IDC_RDelay5           my_struc 125
IDC_RDelay6           my_struc 126
IDC_RDelay7           my_struc 127
IDC_M_CDelay0         my_struc 200
IDC_M_CDelay1         my_struc 201
IDC_M_CDelay2         my_struc 202
IDC_M_CDelay3         my_struc 203    

How I have to use match to get part of the name and use it inside struc declaration? Interesting part is after second underscore or first if it is alone.
Structure looks like this for now
Code:
struc my_struc id {
    .          = id
    .id       dw id
    match ???  \{
            .addr   dq CDelay0  <<for example
    \}
}    
Post 31 Jul 2020, 11:22
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 31 Jul 2020, 11:28
match can't work with partial strings. You would need a separator of some type, like a space, or a comma.

You can work the other way, just pass the final part of the name to the structure and build the full name inside.
Code:
struc my_struc suffix {
  IDC_#suffix dw 0
}    
Post 31 Jul 2020, 11:28
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 31 Jul 2020, 11:41
what about
match a=_b,. { .addr dq b}
Post 31 Jul 2020, 11:41
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 31 Jul 2020, 11:45
The underscore is not a separator character. So, no, it won't work.

We can see in the source code TABLES.INC
Code:
symbol_characters db 27
 db 9,0Ah,0Dh,1Ah,20h,'+-/*=<>()[]{}:,|&~#`;\'    
Post 31 Jul 2020, 11:45
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 31 Jul 2020, 12:14
Code:
match a_b, . \{ .addr dd b\}    

It's trying something
processed: test_3.addr dd b
error: undefined symbol 'b'.

It identified first part of condition, otherwise it's ignore match at all
Post 31 Jul 2020, 12:14
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 31 Jul 2020, 12:16
All that does is define "a_b" to the value "."
Post 31 Jul 2020, 12:16
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 31 Jul 2020, 12:40
Can I use macro processor to get interesting part of name?
Guess I can
Post 31 Jul 2020, 12:40
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 31 Jul 2020, 12:43
You can't use the preprocessor to split strings. There is no code in fasm to do that. You always need one of the separator characters.
Post 31 Jul 2020, 12:43
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 31 Jul 2020, 13:49
Hmm, nope
Code:
        struc my_equ [somedata] {
                common
                .               equ somedata
                .id             dd 0
                local ..string, ..length
                virtual at 0
                ..string:: db `.
                ..length = $
                end virtual
                separ=0
                while % <= ..length
                        load b_1 byte from ..string: (%-1)
                        if separ=1
                                namefinish=namefinish shl 8 + b_1
                        end if
                        if b_1 = '_'
                                separ=1
                                namefinish=''
                        end if
                end while
                if separ=0
                        .addr dq 0
                else
                        .addr dq namefinish
                end if
        }    
Post 31 Jul 2020, 13:49
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 31 Jul 2020, 13:55
That mixes the assembler with the preprocessor.

You also can't construct label names with the assembler. There is no code in fasm to do that either.
Post 31 Jul 2020, 13:55
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.