flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Help creating this macro, please. |
Author |
|
baldr 27 May 2010, 10:49
alorent,
Macro functions are not (yet?) allowed in FASM. Probably struc macro will help? Code: struc MAKE_VALUE rg, rb { . equ ((rg) shl 4 or (rb)) } BASE8 equ 1 BASE16 equ 2 VAL_1 MAKE_VALUE BASE8, 1 VAL_2 MAKE_VALUE BASE8, 2 mov eax, VAL_1 ; EAX = (1 << 4) or 1 mov eax, VAL_2 ; EAX = (1 << 4) or 2 |
|||
27 May 2010, 10:49 |
|
alorent 27 May 2010, 11:44
Thanks baldr!!! That did the trick!
Thanks! |
|||
27 May 2010, 11:44 |
|
baldr 27 May 2010, 12:15
There is another trick to simulate macro functions:
Code: struc reequ [val] { common restore . . equ val } macro ^ [args] { common local head, expr, tail, matched head equ expr equ tail equ matched equ 0 match _head =~ _expr =~ _tail, args \{ head reequ _head expr reequ _expr tail reequ _tail matched reequ 1 \} match =0 _head =~ _expr =~, matched args \{ head reequ _head expr reequ _expr matched reequ 1 \} match =0 =~ _expr =~ _tail, matched args \{ expr reequ _expr tail reequ _tail matched reequ 1 \} match =1, matched \{ \local val match _expr, expr \\{ val _expr head val tail \\} restore val \} match =0, matched \{ args \} restore head, expr, tail, matched } struc RGB r, g, b { . equ (((r) shl 8 or (g)) shl 8 or (b)) } ^ mov eax, ~RGB 1,2,3~+0xFF000000 ^ magenta = ~RGB 255, 0, 255~ mov ecx, magenta |
|||
27 May 2010, 12:15 |
|
alorent 27 May 2010, 12:26
Thanks baldr! Amazing your understanding in FASM macros!!!
|
|||
27 May 2010, 12:26 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.