flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > macro problems with restore.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1314
Roman 23 Dec 2022, 12:01
Fasmw 1.73
Code:
macro buu
{
  if ~ defined buu_int
       buu_int equ 1
       buu_a equ inc eax
       buu_a equ dec edx
       buu_a equ mov esi,1
       display 'a;;'
  end if
       buu_a
       restore buu_a
       display 'b;;'
}  

buu
buu
buu
    

fasm show a;;b;;b;;b;;
But get asm code:
mov esi,1
mov esi,1
mov esi,1

I expected :
mov esi,1
dec edx
inc eax
Post 23 Dec 2022, 12:01
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19084
Location: In your JS exploiting you and your system
revolution 23 Dec 2022, 13:04
Mixing the assembler stage with the preprocessor stage is always tricky.

You can "fix" it with match
Code:
macro buu
{
       local here
  match =buu_int,buu_int \{
       buu_int equ 1
       buu_a equ inc eax
       buu_a equ dec edx
       buu_a equ mov esi,1
       display 'a;;'
  \}
       buu_a
       restore buu_a
       display 'b;;'
}

buu
buu
buu    
However I would recommend you replace the whole section to use the more flexible irpv.
Post 23 Dec 2022, 13:04
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1314
Roman 23 Dec 2022, 13:18
Thanks. Work.

I always forget about: assembler stage with the preprocessor stage is always tricky.
Its introduces me in perplexity.
Post 23 Dec 2022, 13:18
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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.