flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Jin X 14 Apr 2017, 19:16
I can't even use macros for define values
Code: macro set1 { const fix 1 } macro set2 { const fix 2 } Very strange... ![]() |
|||
![]() |
|
Tomasz Grysztar 14 Apr 2017, 20:10
fasm 1 has multiple processing layers and it is important to know what is processed at what stage. INCLUDE is interpreted by the preprocessor, while IF is processed by the assembler. At the time when the assembler sees the source, all the preprocessing has been done already. Similarly FIX is processed even earlier, as an pre-preprocessing task.
|
|||
![]() |
|
Jin X 14 Apr 2017, 20:42
Ok, but how can I include different files (or define "equ"s) depending on some conditions?
I need to include a file depending on const that gets value in "virtual" code block (where I check a code size: 32 or 64-bit). And one more question: why this generates an error? Code: a equ hello macro hello { mov eax,ebx } a But I can't use "fix" because I need to select right value depending on some conditions too... |
|||
![]() |
|
Tomasz Grysztar 14 Apr 2017, 21:04
Jin X wrote: I need to include a file depending on const that gets value in "virtual" code block (where I check a code size: 32 or 64-bit). Jin X wrote: And one more question: why this generates an error? Code: a equ hello macro hello { mov eax,ebx } match value, a { value } |
|||
![]() |
|
Jin X 15 Apr 2017, 08:11
Maybe it's worth to do some conditional preprocessor directives that will branch depending on format (pe/pe64/elf32/elf64), bits (16/32/64), symbols using (like "if used") or definitions (like "if defined") and allow to choose "include" file, make "equ"s (maybe "fix" too) and so on?
![]() |
|||
![]() |
|
Tomasz Grysztar 15 Apr 2017, 09:05
Preprocessor doesn't know about output format because FORMAT is assembler's directive. But it is possible to define a "format" macro and use MATCH to detect what format does it set.
|
|||
![]() |
|
Jin X 31 Jul 2017, 18:56
Ok, but you can realize this feature (define constants for directives and make if directives that works on proprocessor layer - as include)
![]() Is it not possible to include file depending on some constant (equ/fix) value now? |
|||
![]() |
|
ProMiNick 31 Jul 2017, 21:35
Have a nice to play:
Code: ;¤bits equ ¤32;¤64 ; uncomment and play with them or play with conddef ;¤OS equ ¤Windows;¤Linux;¤MenuetOrKolibri ;¤encoding equ ¤ASCII;¤Unicode ;¤language equ ¤RUS;¤ENG macro condinc [cond,flname] { match lft == rgt,cond \{ match rgt,lft \\{ include flname \\} \} } macro conddef [cond,def] { match =cond,cond \{ cond equ def \} } conddef ¤bits,¤64,\ ¤encoding,¤ASCII,\ ¤OS,¤Windows,\ ¤language,¤ENG condinc ¤bits ¤OS ¤encoding = =¤64 =¤Windows =¤ASCII,'win64a.inc',\ ¤bits ¤OS ¤encoding = =¤64 =¤Windows =¤Unicode,'win64w.inc',\ ¤bits ¤OS ¤encoding = =¤64 =¤Linux =¤ASCII,'lnx64a.inc',\ ¤bits ¤OS ¤encoding = =¤64 =¤Linux =¤Unicode,'lnx64w.inc',\ ¤bits ¤OS ¤encoding = =¤64 =¤MenuetOrKolibri =¤ASCII,'men64a.inc',\ ¤bits ¤OS ¤encoding = =¤32 =¤Windows =¤ASCII,'win32a.inc',\ ¤bits ¤OS ¤encoding = =¤32 =¤Windows =¤Unicode,'win32w.inc',\ ¤bits ¤OS ¤encoding = =¤32 =¤Linux =¤ASCII,'lnx32a.inc',\ ¤bits ¤OS ¤encoding = =¤32 =¤Linux =¤Unicode,'lnx32w.inc',\ ¤bits ¤OS ¤encoding = =¤32 =¤MenuetOrKolibri =¤ASCII,'kol32a.inc',\ ¤OS ¤encoding = =¤MenuetOrKolibri =¤Unicode,.err ¤OS unsupport ¤encoding,\ ¤language = =¤RUS,'lang\ru.inc',\ ¤language = =¤ENG,'lang\en.inc' kol32a.inc Code: display 'hello from kolibri32 inc',13,10 include 'x32common.inc' lnx32a.inc Code: display 'hello from linux32a inc',13,10 include 'x32common.inc' lnx32w.inc Code: display 'hello from linux32w inc',13,10 include 'x32common.inc' lnx64a.inc Code: display 'hello from linux64a inc',13,10 include 'x64common.inc' lnx64w.inc Code: display 'hello from linux64w inc',13,10 include 'x64common.inc' men64a.inc Code: display 'hello from menuet64 inc',13,10 include 'x64common.inc' win32a.inc Code: display 'hello from win32a inc',13,10 include 'x32common.inc' win32w.inc Code: display 'hello from win32w inc',13,10 include 'x32common.inc' win64a.inc Code: display 'hello from win64a inc',13,10 include 'x64common.inc' win64w.inc Code: display 'hello from win64w inc',13,10 include 'x64common.inc' x32common.inc Code: display 'hello from x32common inc',13,10 x64common.inc Code: display 'hello from x64common inc',13,10 You can improve macro: with help of local macro can catch default or error cases (1 error case I already add); or you can add one more parametr and do additional operating after all you even can wrap all of it to "¤if" macro, because original "if" is reserved word. and use smthng like Code: ¤if ¤bits ¤OS ¤encoding = =¤64 =¤Windows =¤ASCII,'win64a.inc' instead of ¤ you can use any symbol you like from 128-255 of your codepage, or postfix "if" with such symbol instead of prefixing it. |
|||
![]() |
|
Jin X 01 Aug 2017, 08:26
ProMiNick, thanks!
![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.