Message board for the users of flat assembler.
> Macroinstructions > Macro tutorials -- continuation
Ok, I've gotten a few debug error oages whil trying to psot and delete double post in the "Macro tutorials" thread.
Here is the post which should be there (including the attachent):
3) The 'forward', 'common', and 'reverse' - why they are required, and are there any other directives for macros? I'm really confused with this directives even though I've gone thru the manual. Pls explain a little.
3) Ok, you've read the manual, first: don't panic (), but let's take a look at the docs first: (It's not as much reading as it seems). Second: panic!!!
If after the "macro" directive you enclose some group of arguments' names in square brackets, it will allow giving more values for this group of arguments when using that macroinstruction. Any more argument given after the last argument of such group will begin the new group and will become the first argument of it. That's why after closing the square bracket no more argument names can follow. The contents of macroinstruction will be processed for each such group of arguments separately. The simplest example is to enclose one argument name in square brackets macro stoschar char mov al,char stosb This macroinstruction accepts unlimited number of arguments, and each one will be processed into these two instructions separately. For example "stoschar 1,2,3" will be assembled as the following instructions mov al,1 stosb mov al,2 stosb mov al,3 stosb ...... "forward", "reverse" and "common" directives divide macroinstruction into blocks, each one processed after the processing of previous is finished. They differ in behavior only if macroinstruction allows multiple groups of arguments. Block of instructions that follows "forward" directive is processed for each group of arguments, from first to last - exactly like the default block not preceded by any of these directives . Block that follows "reverse" directive is processed for each group of argument in reverse order - from last to first. Block that follows "common" directive is processed only once, commonly for all groups of arguments. Local name defined in one of the blocks is available in all the following blocks when processing the same group of arguments as when it was defined, and when it is defined in common block it is available in all the following blocks not depending on which group of arguments is processed.
The first macro showed is this:
macro stoschar char mov al,char stosb
It could be written as:
macro stoschar char forward mov al,char stosb
what forward does is that for each argument in char (in the example [char] is three arguments: 1, 2 and 3) is perfomes the code untill either:
1) The macro end.
2) forward, reverse or common is encountered.
The revese does the same as forward, but it starts with the last argument in [char].
macro stoschar char reverse mov al,char stosb stoschar 1,2,3 ;above would be assembled as mov al,3 stosb mov al,2 stosb mov al,1 stosb
common is only processed one, where as forward and common is processed for every argument in [char].
Here is another example from the docs:
macro stdcall proc,