flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > How work Define in match and if ? |
Author |
|
revolution 02 Apr 2023, 01:20
Preprocessor runs first. Assembler runs later.
You can see this in the source fasm.asm Code: ;... call preprocessor call parser call assembler call formatter ;... Code: preprocessor_directives: db 6,'define' dw define_symbolic_constant-directive_handler db 7,'include' dw include_file-directive_handler db 3,'irp' dw irp_directive-directive_handler db 4,'irps' dw irps_directive-directive_handler db 4,'irpv' dw irpv_directive-directive_handler db 5,'macro' dw define_macro-directive_handler db 5,'match' dw match_directive-directive_handler db 8,'postpone' dw postpone_directive-directive_handler db 5,'purge' dw purge_macro-directive_handler db 4,'rept' dw rept_directive-directive_handler db 7,'restore' dw restore_equ_constant-directive_handler db 7,'restruc' dw purge_struc-directive_handler db 5,'struc' dw define_struc-directive_handler db 0 Code: ;... cmp eax,'fix' je define_fix_constant ;... cmp eax,'equ' je define_equ_constant ;... |
|||
02 Apr 2023, 01:20 |
|
Roman 02 Apr 2023, 07:45
preprocessor_directives
How I understood defined do first. |
|||
02 Apr 2023, 07:45 |
|
revolution 02 Apr 2023, 07:54
Define is in the preprocessor.
Defined is in the assembler. But despite the similar name they are not related in their function. They do not compliment each other. |
|||
02 Apr 2023, 07:54 |
|
Roman 02 Apr 2023, 08:30
Ok.
For my case its good solution? Code: define ap 0 match x, P \{ If x eq for define ap a+ecx End if \} ;if I not control when define do. I simple check define If ap = 0 Do variant 1 End if If ap not 0 Do variant 2 End if And what is formatter in fasm? How work formatter? Last edited by Roman on 02 Apr 2023, 08:38; edited 1 time in total |
|||
02 Apr 2023, 08:30 |
|
revolution 02 Apr 2023, 08:38
If is in the assembler. So your define ap a+ecx is always processed if the match succeeds. The If x eq for is useless and does nothing.
|
|||
02 Apr 2023, 08:38 |
|
Roman 02 Apr 2023, 08:41
If x eq for useless.
Ok. How match finded Word for in p ? Code: match x =for, p {}? |
|||
02 Apr 2023, 08:41 |
|
revolution 02 Apr 2023, 08:47
For the preprocessor version of "if" use "match".
|
|||
02 Apr 2023, 08:47 |
|
revolution 02 Apr 2023, 08:48
Do you want p (or P). matched to "for"?
Code: match =for, p { ;... } |
|||
02 Apr 2023, 08:48 |
|
Roman 02 Apr 2023, 09:12
match =for, p {} not working !
Code: ;compiled in fasmw 1.73 eggs equ for,8 ;or eggs equ for 8 ar = 0 match =for, eggs { ar = 1 } match =run, eggs { ar = 2 } display ar+48,13,10 ;fasm show ar =0 This work fine ! Code: macro uu p { ar = 0 match =for x, p \{ ar = 1 display 'match find for',13,10 \} } eggs equ for,8 uu eggs display ar+48,13,10 ;show ar = 1 uu <for 11> display ar+48,13,10 ;show ar = 1 ;this variant work too macro uu p { define ar 0 match =for x, p \{ define ar 1 display 'match find for',13,10 \} } |
|||
02 Apr 2023, 09:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.