flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > macro for arg.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 26 Jul 2020, 15:33
I need write macro to ignor or use last parameter.
PutVal macro get only 3 or 4 params
Code:
PutVal 10,20,30,mem1 
PutVal 12,13,22

PutVal 1,0,3,mem2
PutVal 2,3,11
    


This give this code:
Code:
;----first PutVal
mov eax,mem1
mov [eax],10
mov [eax+4],20
mov [eax+8],30
add eax,12
;----second PutVal
mov [eax],12
mov [eax+4],13
mov [eax+8],22
add eax,12
;----3 PutVal
mov eax,mem2
mov [eax],1
mov [eax+4],0
mov [eax+8],3
add eax,12
;----4 PutVal
mov [eax],2
mov [eax+4],3
mov [eax+8],11
add eax,12
    
Post 26 Jul 2020, 15:33
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 26 Jul 2020, 18:09
Code:
macro PutVal V1*, V2*, V3*, Addr
{
  match any , Addr \{ mov eax, Addr \}
  mov dword [eax], V1
  mov dword [eax + 4], V2
  mov dword [eax + 8], V3
  add eax, 12
}    


I wrote this directly in browser but it should work. You may also want to check for mov eax, eax case, etc. I doubt such macros are of large usefulness though.
Post 26 Jul 2020, 18:09
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 26 Jul 2020, 18:33
Thanks ! Work

Question. Why need write V1* ?
Post 26 Jul 2020, 18:33
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 26 Jul 2020, 18:45
It is not mandatory. But this makes FASM ensure that something non-empty is passed as this parameter. See Section 2.3.3 for details.
Post 26 Jul 2020, 18:45
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.