flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Union for macros. |
Author |
|
Roman 31 Dec 2023, 05:19
Code: macro a1 v,f=0 { local .1 if f = 0 cmp dword [v],0 jz .1 end if inc v .1: } macro b1 v,f=0 { local .1 if f = 0 cmp dword [v],0 jz .1 end if add v,2 .1: } macro c1 v,f=0 { local .1 if f = 0 cmp dword [v],0 jz .1 end if dec v .1: } macro aa v,mtk { cmp v,0 jz mtk } macro munion a,v,[b] { common local .1 a v,.1 forward b v,1 common .1: } val1 dd 0 Start: mov eax,val1 a1 eax b1 eax c1 eax munion aa,byte [eax],a1,b1,c1 munion aa,dword [eax],a1,b1,c1 munion aa,eax,a1,b1,c1 |
|||
31 Dec 2023, 05:19 |
|
Overclick 31 Dec 2023, 08:27
Classic union means different data, names or types for the same location for different scenarios of use. So why you call your macro as union? Anyway, you want your macro to insert some group of instructions but avoid cmp then remove it or turn it off as you started to do by if IF instruction. Or do some like this
Code: macro conveyor operand, [car] { cmp [operand], 0 je @F forward car operand common @@: } |
|||
31 Dec 2023, 08:27 |
|
macomics 31 Dec 2023, 10:41
Why be so tricky. Just put the shared code in a separate macro and use it as a union.
Code: macro a1@body v { inc v } macro a1 v,f=0 { local .1 if f = 0 cmp dword [v],0 jz .1 end if a1@body v .1: } macro b1@body v { add v, 2 } macro b1 v,f=0 { local .1 if f = 0 cmp dword [v],0 jz .1 end if b1@body v .1: } macro c1@body v {dec v } macro c1 v,f=0 { local .1 if f = 0 cmp dword [v],0 jz .1 end if c1@body v .1: } macro aa v,mtk { cmp v,0 jz mtk } macro munion a,v,[b] { common local .1 a v,.1 forward b v,1 common .1: } val1 dd 0 Start: mov eax,val1 a1 eax b1 eax c1 eax munion aa,byte [eax],a1@body,b1@body,c1@body munion aa,dword [eax],a1@body,b1@body,c1@body munion aa,eax,a1@body,b1@body,c1@body |
|||
31 Dec 2023, 10:41 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.