Suppose I want to have each of my files have the following structure:
; Macros, constants, structure definitions, etc. go here
data ; Initialized data
dwSomeValue dd 42
MoreData COMPLEXSTRUCT 1, 2, 3, <4, 5>
data? ; Uninitialized data
dwMyData dd ?
MoreData COMPLEXSTRUCT
code ; Code
proc MyProc
ret
endp
The purpose is to avoid having multiple files for related stuff and to automate the process of gathering the pieces together at proper points in the main program. This part is an easy one.
The difficult part is about the syntax shown in the example. In fact, each of the “keywords” should wrap the text until the next “keyword” (or the end of file) into a macro. Which brings the problem of closing properly the preceding macro.
One easy solution is to transform each “keyword” into a macro header and use a slightly modified syntax:
data
{
dwSomeValue dd 42
MoreData COMPLEXSTRUCT 1, 2, 3, <4, 5>
}
Another easy solution is to introduce a set of special closing “keywords”:
enddata fix }
enddata? fix }
endcode fix }
...
and then use the “keywords” in pairs. Has additional problems if the file content is put into one or more preprocessor blocks.
Is the exact
section-like syntax I’ve shown in the first example really implementable with FASM macros? Any ideas?