flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > using macros to pick data types

Author
Thread Post new topic Reply to topic
aq83326



Joined: 25 Jun 2011
Posts: 21
aq83326
Having trouble.

I tried using a match directive to automatically put size operands in front of [rcx] and after "add rcx," but I kept getting "incomplete macro"
Code:
 match a b , byte  1
{
        movzx r9, a [rcx]
        add rcx, b
}    

At first the size of each action was a parameter to the macro,
Code:
match =1 , actionsize { movzx r9, byte [rcx]}
match =2 , actionsize {movzx r9, word [rcx]
etc..
add rcx, actionsize    

then I tried the above code but instead of a parameter to the macro I made it a symbolic constant
Code:
actionsize equ 1    

but nothing works.
Code:
use64 ; very important this line

macro DeterministicFiniteAutomatonState Name, StateType, InvalidAction, [next, action]
{
    common
      Name:
        cmp rcx, rdx         ; compare curenrt Address, RCX, and end Address, RDX, if they are the same, we have reached the end of the string
        je StateType         ; jump to StateType (ST should tell us whether this state is an Accepting state or not)
        movzx r9, byte [rcx] ; retrieve the value pointed at by current address, put it in R9
        add rcx, 1           ; increment the current address pointer by size bytes
    forward
        cmp r9, action      ; compare what's in R9 to the given action argument
        je next             ; if equal, jump to the next state, else pass through to the next comparison
    common
        jmp InvalidAction   ; if we get to this point, the current action is invalid, so Jump to InvalidAction
}    
Post 22 Oct 2011, 17:39
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: 17716
Location: In your JS exploiting you and your system
revolution
When you use match inside a macro definition you have to "escape" the closing curly bracket with a backslash:
Code:
macro ... {
  match ... \{
   ;,,,
  \} ;close the match
} ;close the macro    


Moved to macroinstructions
Post 22 Oct 2011, 17:45
View user's profile Send private message Visit poster's website Reply with quote
aq83326



Joined: 25 Jun 2011
Posts: 21
aq83326
Thanks!
Post 24 Oct 2011, 02: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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.