flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > macro to generate hdd image |
Author |
|
l_inc 09 Mar 2015, 00:51
zhak
Your code has quite a number of problems: 1) There's no way to check if a macro is already defined. The if directive is an assembly time directive. Hence the first line checks if there's no assembly time variable/constant or label named "struct" that can be used at this particular source code location. The condition is true, no matter if "struct.inc" was included before or not. 2) As for the second line of code: ....a) It is a bad idea to explicitly expand the include variable. It may contain multiple paths and it's expanded implicitly anyway. The correct include string is include "macro/struct.inc" . ....b) As long as if is an assembly time directive, it is not able to prevent processing of the preprocessor directive include. Hence "struct.inc" will be included no matter if the condition is true or false. As for the rest some things are suboptimal but generally look OK. Regarding you questions: 1. The struct macro defines a macro and a struc named as the name passed to the struct macro. Both take a list of the arguments composed of the fields of the struct. Thus much better would be to fill the partition table by invoking the automatically created mbr_partition_record_entry macro at its definition location. This would require you to redesign the macros a bit. 2. If you properly redesign the macros (as suggested before), the index will no longer be needed by design in a natural way. 2. (Yes, the second second point ) The @ symbol is for nothing. It has no special meaning for the assembler, but it's a naming convention for globally accessible symbols in some official macros. It literally means "[a symbolic constant called] field at struct [related macros / header file]". I generally consider using this naming convention to be worse than generating unique names with the local directive. However you need to enclose your macros into a single macroblock to be able to share such a generated name across them. Look here for an example. 3. If you properly redesign the macros (as suggested before), you'll naturally see what you need to put there. It is however additionally advisable to define the partition macro inside the image macro and to purge it inside the endi macro. This way you'll be able to restrict the use of the partition macro to the scope of the image description. As for the "struct.inc" I think it's too complicated for learning basics from it. _________________ Faith is a superposition of knowledge and fallacy |
|||
09 Mar 2015, 00:51 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.