flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Discussion strategy flexible macro. |
Author |
|
Roman 01 Apr 2023, 09:24
First variant.
Code: ;one uneversal macro flex others simple ;in flex hidden for,while macro flex a,[p] { local .up common cnt = 0 forward match x d, p \{ if x eq for display 'for',13,10 ;a equ a+ecx define a a+ecx cnt = d end if \} match x, p \{ if x eq while display 'while',13,10 define a a+ecx end if \} match x d, p \{ if x eq mout if cnt > 0 xor ecx,ecx .up: mout [a],d+ecx end if if cnt = 0 mout [a],d end if if cnt > 0 inc ecx cmp ecx,cnt jb .up end if end if \} } macro mout reg,buf { mov bl,reg mov [buf],bl } ;in code ptxt db 128 dup (0) ptxt2 db 128 dup (0) flex eax,<for 20>,<mout ptxt2> ;asm code as expected. Ok flex edx,<mout ptxt> ;ida pro show mov bl,[edx+ecx] ! Why ? I expected mov bl,[edx] ;another problem define a+ecx in macro flex broken Out1 name. flex Out1,<mout ptxt> ;section bss Out1 rd 20 ;fasm error Out1+ecx |
|||
01 Apr 2023, 09:24 |
|
Roman 01 Apr 2023, 14:10
Variant fixed problems
Code: macro flex a,[p] { local .up common cnt = 0 define _a2 a forward match x d, p \{ if x eq for display 'for',13,10 define _a2 a+ecx cnt = d end if \} match x, p \{ if x eq while display 'while',13,10 define _a2 a+ecx end if \} match x d, p \{ if x in <mout,minc> if cnt > 0 xor ecx,ecx .up: x [_a2],d+ecx end if if cnt = 0 x [a],d end if if cnt > 0 inc ecx cmp ecx,cnt jb .up end if end if \} } |
|||
01 Apr 2023, 14:10 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.